On Oct 11, 7:16 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > Is there a problem with writing C like this? > > class C(object): > def __init__(self): > logging.warn('Allocating resource ...') > self.__log = logging.warn > def __del__(self): > self.__log('De-allocating resource ...') > print 'THIS IS REACHED!' > > It works for me. Have I missed something?
Another more common workaround is to use default arguments: class C(object): def __init__(self): logging.warn('Allocating resource ...') def __del__(self, warn=logging.warn): warn('De-allocating resource ...') print 'THIS IS REACHED!' But, as you know, I want to remove __del__ because of the problem with reference cycles, not because of this little issue with the cleanup mechanism (which BTW is shared also by the weak references callback mechanism). Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list