Replace Whole Object Through Object Method

Bruno Desthuilliers onurb at xiludom.gro
Tue Jun 27 13:05:25 CEST 2006


Fredrik Lundh wrote:
> Bruno Desthuilliers wrote:
> 
> 
>>As a matter of fact, in Python, the class is an attribute of an object.
> 
> 
> except when it isn't.

Which are the cases where it isn't ?

> 
>>>def add_role(self, role_class):
>>>   self.roles.append(role_class(self))
>>
>>And here you create a circular reference between object and roles...
> 
> 
> and ?  Python has a garbage collector, you know...

Yes. But garbage collection is not cost-free AFAIK.


-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"



More information about the Python-list mailing list