I wrote this little piece of code to get a list of relative paths of
all files in or below the current directory (*NIX):

    walkList  = [(x[0], x[2]) for x in os.walk(".")]
    filenames = []
    for dir, files in walkList:
        filenames.extend(["/".join([dir, f]) for f in files])

It works fine, I don't need to change it, but I know there is a one
liner list/generator comprehension to do this - I'm just not well
enough versed in comprehensions to figure it out. Can someone please
show me what it is?

Even better, is there a generalized way to transform simple loops into
comprehensions that someone can point me to?

james

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to