Re: destructor not called

2008-09-29 Thread Bruno Desthuilliers
Marcin201 a écrit : Others have already replied to your main question; in short you shouldn't rely on __del__ being called. Regardless, is there a (good) reason for having an instance reference to the method ? Without further information, that seems like a code smell. I have dictionary of fxns

Re: destructor not called

2008-09-29 Thread Marcin201
> Others have already replied to your main question; in short you > shouldn't rely on __del__ being called. Regardless, is there a (good) > reason for having an instance reference to the method ? Without > further information, that seems like a code smell. I have dictionary of fxns to do import/ex

Re: destructor not called

2008-09-28 Thread George Sakkis
On Sep 28, 12:00 pm, Marcin201 <[EMAIL PROTECTED]> wrote: > I have a class which uses a temporary directory for storing data.  I > would like that directory to be removed when the class is no longer > used.  I have tried removing the temporary directory from the class > destructor, however, it was

Re: destructor not called

2008-09-28 Thread Michel Leunen
Marcin201 a écrit : class Foo: def __init__(self): print "Hello" self.f = self.fxn Maybe self.f = self.fxn() is what you want. Note the '()'. -- Michel Leunen http://linux.leunen.com -- http://mail.python.org/mailman/listinfo/python-list

Re: destructor not called

2008-09-28 Thread Roy Smith
In article <[EMAIL PROTECTED]>, Marcin201 <[EMAIL PROTECTED]> wrote: > I have a class which uses a temporary directory for storing data. I > would like that directory to be removed when the class is no longer > used. I have tried removing the temporary directory from the class > destructor, ho

Re: destructor not called

2008-09-28 Thread Szabolcs Ferenczi
On Sep 28, 6:00 pm, Marcin201 <[EMAIL PROTECTED]> wrote: > I have a class which uses a temporary directory for storing data.  I > would like that directory to be removed when the class is no longer > used.  I have tried removing the temporary directory from the class > destructor, however, it was n

destructor not called

2008-09-28 Thread Marcin201
I have a class which uses a temporary directory for storing data. I would like that directory to be removed when the class is no longer used. I have tried removing the temporary directory from the class destructor, however, it was never called. After I while I traced the problem to the class hav

Re: global destructor not called?

2007-06-18 Thread Duncan Booth
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: >> >> def __del__ (self): >> >> try: >> >> os.remove (self.name + '.old') >> >> except: >> >> pass >> >> >> And setting: >> >> sys.stderr = logger(...) >> >> >> It seems my cleanup (__del__) is never called,

Re: global destructor not called?

2007-06-17 Thread [EMAIL PROTECTED]
On Jun 15, 7:07 pm, Neal Becker <[EMAIL PROTECTED]> wrote: > Bruno Desthuilliers wrote: > > Neal Becker a écrit : > >> To implement logging, I'm using a class: > > > If I may ask : any reason not to use the logging module in the stdlib ? > > Don't exactly recall, but needed some specific behavior a

Re: global destructor not called?

2007-06-15 Thread Neal Becker
Bruno Desthuilliers wrote: > Neal Becker a écrit : >> To implement logging, I'm using a class: > > If I may ask : any reason not to use the logging module in the stdlib ? Don't exactly recall, but needed some specific behavior and it was just easier this way. > >> class logger (object): >>

Re: global destructor not called?

2007-06-15 Thread Bruno Desthuilliers
Neal Becker a écrit : > To implement logging, I'm using a class: If I may ask : any reason not to use the logging module in the stdlib ? > class logger (object): > def __init__ (self, name): > self.name = name > self.f = open (self.name, 'w') > def write (self, stuff): >

global destructor not called?

2007-06-15 Thread Neal Becker
To implement logging, I'm using a class: class logger (object): def __init__ (self, name): self.name = name self.f = open (self.name, 'w') def write (self, stuff): self.f.write (stuff) def close (self): self.f.close() def flush (self): self.f.