Bizzare lst length problem

Fredrik Lundh fredrik at pythonware.com
Sun Oct 8 07:19:47 EDT 2006


Ben wrote:

> The output from this would be (for a given key value):
>                 Number:	181
>                 Level:	ovride+supvis
>                 Location:	 mons=4 v8.0 3rd floor
>                 MOPS:	['287', '288', '289', '290']
>                 List Length:	28
>                 Matrix:	kng
> 
> This is really odd...my len(v.mops) ought to return 4 (4 elements in
> the list).

adding a

     print type(v.mops), repr(v.mops)

debug statement might provide you with the clues you need.

 > In fact it returns 28. looking at outputs from lots of
> records, it seems that the length is almost always 7 time too great
> (28/7=4)....but not always.

 >>> len("['287',")
7
 >>> len(" '288',")
7
 >>> len(" '289',")
7
 >>> len(" '290']")
7

</F>




More information about the Python-list mailing list