Bizzare lst length problem
Bruno Desthuilliers
onurb at xiludom.gro
Mon Oct 9 07:01:55 EDT 2006
Ben wrote:
> Ah... my list is a string. That explains the len() results, but not why
> it is a string in the dirst place.
>
> I have a dictionary containing a number of instances of the following
> class as values:
>
> class panel:
> mops =[]
This one is a class attribute - it's shared between all instances of panel.
> def __init__(self,number,level,location,mops,matrix):
> self.number=number
> self.level=level
> self.location=location
> self.mops=mops
And here, you create an instance attribute with the same name, that will
shadow the class attribute.
> self.matrix=matrix
>
>
> abve mops is a list, yet when I access it it is a string...
the class attribute 'mops' is a list. The instance attribute 'mops' is
whatever you passed when instanciating panel.
--
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