order that destructors get called?
Alf P. Steinbach
alfps at start.no
Thu Apr 8 21:30:10 EDT 2010
* Brendan Miller:
> Thanks Steven and Gabriel. Those are very informative responses.
>
> In my case my resource isn't bound to a lexical scope, but the:
>
> def __del__(self,
> delete_my_resource=delete_my_resource):
>
> pattern works quite well. I've made sure to prevent my class from
> being part of a circular reference, so that the __del__ shouldn't be
> an issue.
It may work but is unfortunately not guaranteed to work.
Use a 'with' statement where you need guaranteed cleanup.
Cheers & hth.,
- Alf
More information about the Python-list
mailing list