does python have useless destructors?

Tim Bradshaw tfb+google at tfeb.org
Fri Jun 11 17:44:39 CEST 2004


"Delaney, Timothy C (Timothy)" <tdelaney at avaya.com> wrote in message news:<mailman.780.1086840001.6949.python-list at python.org>...

> 
> myfile = open("myfilepath", "w")
> 
> try:
>     myfile.write(reallybigbuffer)
> finally:
>     myfile.close()
> 

I don't think this is save.  Is it certain that there can be no
problem between the open and the try?  The expansion of Lisp macros
which do this typically look like:

myfile = None

try:
    myfile = open(...)
   ...
finally:
    if myfile
         myfile.close()



More information about the Python-list mailing list