Python os.caminar + seguir enlaces simbólicos


¿Cómo consigo que esta pieza siga enlaces simbólicos en python 2.6?

def load_recursive(self, path):
    for subdir, dirs, files in os.walk(path):
        for file in files:
            if file.endswith('.xml'):
                file_path = os.path.join(subdir, file)
                try:
                    do_stuff(file_path) 
                except:
                    continue
Author: F. Malina, 2010-09-22

1 answers

Establezca followlinks en True. Este es el cuarto argumento del método os.walk, reproducido a continuación:

os.walk(top[, topdown=True[, onerror=None[, followlinks=False]]])

Esta opción fue añadida en Python 2.6.

 45
Author: Richard Cook,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2010-09-22 16:58:55