errors and exception

Daniel Urban urban.dani at gmail.com
Mon Aug 16 09:40:45 CEST 2010


> f = open("myfile.txt")
> for line in f:
>   print line
> f.close()   # This is what the "with" statement guarantees; so now just do
> it yourself

Not exactly. More like:

f = open("myfile.txt")
try:
    for line in f:
        print line
finally:
    f.close()


Daniel



More information about the Python-list mailing list