Bizzare lst length problem

John Machin sjmachin at lexicon.net
Sun Oct 8 09:03:28 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 =[]
>
>     def __init__(self,number,level,location,mops,matrix):
>          self.number=number
>          self.level=level
>          self.location=location
>          self.mops=mops
>          self.matrix=matrix
>
>
> abve mops is a list, yet when I access it it is a string...
>

Well, if you are going to spare us from reading all of your code,
you'll have to debug it yourself. The clue that Fredrik gave you is
*not* of the use-once-and-discard variety -- when you are having
problems with the pixies changing your lists into strings, you need to
sprinkle prints of type(pixie_prey) and repr(pixie_prey) at salient
points in your code; as first statement in that __init__ method would
be a good start.




More information about the Python-list mailing list