def images():
 for (ci, cl) in enumerate(classes):
  images = glob('{}/{}/*.jpg'.format(basedir, cl))
  for im in sorted(images):
   (yield (im, ci))

def images ( ) : for ( ci , cl ) in enumerate ( classes ) : images = glob ( '{}/{}/*.jpg' . format ( basedir , cl ) ) for im in sorted ( images ) : ( yield ( im , ci ) )
iterate over all pairs this function will return .