[BangPypers] Simulating atexit using weakref (was How to run a block of code just before the interpreter is being exited ...)

Noufal Ibrahim noufal at nibrahim.net.in
Tue Sep 10 08:43:17 CEST 2013


Anand Chitipothu <anandology at gmail.com> writes:


[...]

> You can also achieve the same using __del__.
>
> class Foo:
>     def __del__(self):
>         print "on exit"
>
> foo = Foo()
>
> if __name__ == '__main__':
>     print 3+4
>     print 8+9

This whole business is kind of surreptitious. 

The PyODE library had a "world" object which can hold multiple
geometries in it. Once you add it to the world, you expect it to keep
track of the geometries. However, it doesn't and if the geometry objects
go out of scope, it actually removes them from the world messing
everything up. To keep them in there, you have to keep some references
in Python land to the objects by putting them in a list or something.


[...]


-- 
Cordially,
Noufal
http://nibrahim.net.in


More information about the BangPypers mailing list