Simple questions on use of objects (probably faq)

bruno at modulix onurb at xiludom.gro
Thu Mar 9 07:47:39 EST 2006


Brian Elmegaard wrote:
> bruno at modulix <onurb at xiludom.gro> writes:
> 
> 
>>So it's time to move to 2.4x !-)
> 
> 
> I guess so.
> 
> 
> 
>>What is "going wrong" exactly ?
> 
> 
>   def _add_instance(cls, instance):
>       _add_instance=classmethod(_add_instance)
>       cls._instances.append(instance)

You want

def _add_instance(cls, instance):
  cls._instances.append(instance)

_add_instance=classmethod(_add_instance)


(snip)

>>Also, if you intend to use such a solution (with or without multiple
>>lists), you may want to add a classmethod to delete instances from the
>>list(s).
> 
> 
> I will have to study classmethods.

May I suggest that you first learn the language syntax and basics ?-)

FWIW, a classmethod is a method that get the class object as first
argument (instance methods get a reference to the instance).


-- 
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