dumping in destructor

Митя netimen at gmail.com
Mon Oct 20 07:42:59 EDT 2008


Thanks for your answers!

my g_register is a global register, wich contains all my objects and
lives all the program lifetime. So 'with' is not appliable. Am I
right?

But using atexit sounds to be a good solution

On Oct 20, 1:58 pm, Michele Simionato <michele.simion... at gmail.com>
wrote:
> On Oct 20, 10:12šam, íÉÔÑ <neti... at gmail.com> wrote:
>
> > But when g_register is being destroyed, dump seems to be already dead,
> > so I get:
>
> > Exception exceptions.TypeError: "'NoneType' object is not callable" in
> > <bound method __Register.__del__ of <MyWiki.Register.__Register object
> > at 0x835a74c>> ignored
>
> > can I somehow save my data from destructor?
>
> The best thing is to use the 'with' statement, but it requires you to
> rewrite all
> of your code. Alternatively you can use the atexit module. I wrote
> once a
> recipe that may be of interest to you:
>
> http://code.activestate.com/recipes/523007/




More information about the Python-list mailing list