On Jun 29, 6:44 am, Douglas Alan <[EMAIL PROTECTED]> wrote:
>
> I've written plenty of Python code that relied on destructors to
> deallocate resources, and the code always worked.
You have been lucky:
$ cat deallocating.py
import logging
class C(object):
def __init__(self):
logging.warn('Allocating resource ...')
def __del__(self):
logging.warn('De-allocating resource ...')
print 'THIS IS NEVER REACHED!'
if __name__ == '__main__':
c = C()
$ python deallocating.py
WARNING:root:Allocating resource ...
Exception exceptions.AttributeError: "'NoneType' object has no
attribute 'warn'" in <bound method C.__del__ of <__main__.C object at
0xb7b9436c>> ignored
Just because your experience has been positive, you should not
dismiss the opinion who have clearly more experience than you on
the subtilities of Python.
Michele
--
http://mail.python.org/mailman/listinfo/python-list