def walksymlinks(top, topdown=True, onerror=None):
 for (dirpath, dirnames, filenames) in os.walk(top, topdown, onerror):
  if topdown:
   (yield (dirpath, dirnames, filenames))
  symlinks = filter((lambda dirname: os.path.islink(os.path.join(dirpath, dirname))), dirnames)
  for s in symlinks:
   for x in walksymlinks(os.path.join(dirpath, s), topdown, onerror):
    (yield x)
  if (not topdown):
   (yield (dirpath, dirnames, filenames))

def walksymlinks ( top , topdown = True , onerror = None ) : for ( dirpath , dirnames , filenames ) in os . walk ( top , topdown , onerror ) : if topdown : ( yield ( dirpath , dirnames , filenames ) ) symlinks = filter ( ( lambda dirname : os . path . islink ( os . path . join ( dirpath , dirname ) ) ) , dirnames ) for s in symlinks : for x in walksymlinks ( os . path . join ( dirpath , s ) , topdown , onerror ) : ( yield x ) if ( not topdown ) : ( yield ( dirpath , dirnames , filenames ) )
same as os .