Re: dumping in destructor

2008-10-21 Thread Gabriel Genellina
En Tue, 21 Oct 2008 10:31:58 -0200, Митя <[EMAIL PROTECTED]> escribió: Thank you! I have already implemented custom load/save operations without pickle. And they work fine on atexit. Just for information: pickle.dump worked OK when called manually, but being called by atexit it produeced the ab

Re: dumping in destructor

2008-10-21 Thread Митя
Thank you! I have already implemented custom load/save operations without pickle. And they work fine on atexit. Just for information: pickle.dump worked OK when called manually, but being called by atexit it produeced the above described error. I don't know why. On Oct 21, 7:54 am, "Gabriel Genell

Re: dumping in destructor

2008-10-20 Thread Gabriel Genellina
En Mon, 20 Oct 2008 10:01:07 -0200, Митя <[EMAIL PROTECTED]> escribió: Thank you for your answers! my g_register is a global object, and it lives all the program's lifetime, so 'with' is not appliable. Am I right? Why not? You could use a with statement (or try/finally) around your main ent

Re: dumping in destructor

2008-10-20 Thread Митя
Thank you for your answers! my g_register is a global object, and it lives all the program's lifetime, so 'with' is not appliable. Am I right? I tried to use atexit and wrote following: class _Register(object): def dump(self): class Registerable(object): g_register = _

Re: dumping in destructor

2008-10-20 Thread Митя
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 <[EMAIL PROTECTED]> wrote: > On Oct 20, 10:12š

Re: dumping in destructor

2008-10-20 Thread Michele Simionato
On Oct 20, 10:12 am, Митя <[EMAIL PROTECTED]> 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 > at 0x835a74c>> ignored > > can I somehow save my data from destructor? The best th

Re: dumping in destructor

2008-10-20 Thread Hrvoje Niksic
Митя <[EMAIL PROTECTED]> writes: > I have a class which I want to save it's data automatically on disc, > when it's destroyed. I have following code: > > from cPickle import dump > > class __Register(object): > def __init__(self): > self.dict = {} > def __del__(self): > fh

Re: dumping in destructor

2008-10-20 Thread robert
Митя wrote: I have a class which I want to save it's data automatically on disc, when it's destroyed. I have following code: from cPickle import dump class __Register(object): def __init__(self): self.dict = {} def __del__(self): fh = open('aaa', 'w') dump(self.d

Re: dumping in destructor

2008-10-20 Thread Marc 'BlackJack' Rintsch
On Mon, 20 Oct 2008 01:12:06 -0700, Митя wrote: > I have a class which I want to save it's data automatically on disc, > when it's destroyed. I have following code: > > from cPickle import dump > > class __Register(object): > def __init__(self): > self.dict = {} > def __del__(sel

dumping in destructor

2008-10-20 Thread Митя
I have a class which I want to save it's data automatically on disc, when it's destroyed. I have following code: from cPickle import dump class __Register(object): def __init__(self): self.dict = {} def __del__(self): fh = open('aaa', 'w') dump(self.dict, fh)