Class decorator to capture the creation and deletion of objects

2014-02-24 Thread Sangeeth Saravanaraj
This question was initially asked in tu...@python.org; Now I am widening the audience to gain attention. I want to create a decorator which should do the following things: => When an object of the decorated class is created, the objects name (say the value of the incoming "id" argument) should be

Re: [Baypiggies] Class decorator to capture the creation and deletion of objects

2014-02-24 Thread Chris Angelico
On Tue, Feb 25, 2014 at 4:26 PM, alex23 wrote: > On 25/02/2014 12:34 PM, Chris Angelico wrote: >> >> On Tue, Feb 25, 2014 at 1:24 PM, Alex Martelli wrote: >>> >>> At this point, all entries in the table should be deleted; query should >>> return an empty list! >> >> >> You can't actually depend o

Re: [Baypiggies] Class decorator to capture the creation and deletion of objects

2014-02-24 Thread alex23
On 25/02/2014 12:34 PM, Chris Angelico wrote: On Tue, Feb 25, 2014 at 1:24 PM, Alex Martelli wrote: At this point, all entries in the table should be deleted; query should return an empty list! You can't actually depend on del resulting in __del__ being called. Mind those attributions, Chri

Re: [Baypiggies] Class decorator to capture the creation and deletion of objects

2014-02-24 Thread Jacob Alheid
— Sent from Mailbox for iPad On Mon, Feb 24, 2014 at 8:49 PM, David Lawrence wrote: > If as according to the docs, there is no guarantee of __del__ being called, > anything that relies on that seems unsafe (depending on how robust one > needs the solutions to be). Solutions I've seen elsewhere

Re: [Baypiggies] Class decorator to capture the creation and deletion of objects

2014-02-24 Thread David Lawrence
If as according to the docs, there is no guarantee of __del__ being called, anything that relies on that seems unsafe (depending on how robust one needs the solutions to be). Solutions I've seen elsewhere suggest creating something like a *release()* method on your objects and calling it explicitl

Re: [Baypiggies] Class decorator to capture the creation and deletion of objects

2014-02-24 Thread Chris Angelico
On Tue, Feb 25, 2014 at 1:24 PM, Alex Martelli wrote: > del a1 > del a2 > del a3 > del b1 > del b2 > > At this point, all entries in the table should be deleted; query should > return an empty list! > You can't actually depend on del resulting in __del__ being called. The two are tangentially rel