is a file open ?

John Machin sjmachin at
Wed Jul 20 06:57:06 EDT 2005

luis wrote:
> for root, dirs, files in os.walk(path):
>    for file in files:
>       # ¿ is opened ?

¡ rtfm ! "files" is a list of fileNAMEs -- i.e. strings.
¿ How could you possibly imagine that your sample code would open a 
file? What a design-nonsense that would be: instant complaints from folk 
who wanted to do some further selection before opening (if they ever 
wanted to open the files at all).
¿ Did you contemplate *trying* this code to see what happened ?
¡ Don't use "file" as a name; it shadows the built-in file function !

More information about the Python-list mailing list