[Tutor] need some class / module help

Python python at venix.com
Fri Oct 20 21:11:40 CEST 2006


On Fri, 2006-10-20 at 13:44 -0500, shawn bright wrote:
> if i name them, like bob = group.Group(some_id) ?
> 
> what is going to happen is that each time, the variable will create a
> different object
> 
> like 
> while 1:
>     group = group.Group(some_id)
>     do some stuff with group. 
> 
> so since it keeps getting replaced, it should be ok without some way
> to destroy it ?

You can verify this by putting some kind of signal in the __del__
method.  For instance:

>>> class A:
...     def __del__(self): print "destroyed"
...
>>> bob = A()
>>> bob = A()
destroyed
>>> dir()
['A', '__builtins__', '__doc__', '__name__', 'bob']


So you can see that binding the name "bob" to a different instance
resulted in destroying the first one.

>
> 
> thanks
> 
> 
> On 10/20/06, Simon Brunning <simon at brunningonline.net> wrote:
>         On 10/20/06, shawn bright <nephish at gmail.com> wrote:
>         > oh, one more thing.
>         > these objects are going to be created at the rate of about
>         20 / minute in a
>         > thread.
>         > at some point is this going to be a problem ? do they go
>         away over time? 
>         > Or do i need to write something that will kill them?
>         
>         If you don't keep references too them (i.e. by having names
>         that are
>         bound to them, or by keeping them in collections) then they'll
>         go away
>         - usually as soon as the last reference to them is gone. 
>         
>         --
>         Cheers,
>         Simon B
>         simon at brunningonline.net
>         http://www.brunningonline.net/simon/blog/
>         _______________________________________________ 
>         Tutor maillist  -  Tutor at python.org
>         http://mail.python.org/mailman/listinfo/tutor
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
-- 
Lloyd Kvam
Venix Corp



More information about the Tutor mailing list