Anonymous file closing

Sergey Krushinsky skru at ptc.ru
Fri Jun 11 09:41:51 EDT 2004


Peter Hansen wrote:

> Duncan's response says it all, but here's the solution
> if you don't like the uncertainty inherent in the above:
>
> f = open(filename, 'r')
> try:
>     text = f.read()
> finally:
>     f.close()
>
But the uncertainty remains in case of an anonymous file, doesn't it?

Sergey




More information about the Python-list mailing list