Re: Bizzare lst length problem

2006-10-09 Thread Bruno Desthuilliers
Ben wrote: (OT : Ben, please stop top-posting, it's really annoying)0 > Ah - I found out why I had cast it to a string. cf my previous anwser on this point. > I had not, at that > point, worked out ho to pass the list by value rather than reference, There's nothing like 'pass by value/pass by r

Re: Bizzare lst length problem

2006-10-09 Thread Bruno Desthuilliers
Ben wrote: > Using Fredericks advice I managed to track down the problem - it was > really very stupid. I had accidentally cast the list to a string There's nothing like "type casting" in Python. You did not "cast the list to a string", you created a string from a list. -- bruno desthuilliers py

Re: Bizzare lst length problem

2006-10-09 Thread Bruno Desthuilliers
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 betwe

Re: Bizzare lst length problem

2006-10-08 Thread John Machin
Ben wrote: > Ah - I found out why I had cast it to a string. I had not, at that > point, worked out ho to pass the list by value rather than reference, > and so was casting to a string as a stopgap measure that I then forgot > about. Now the problem is fixed after this group told me how to pass a

Re: Bizzare lst length problem

2006-10-08 Thread Fredrik Lundh
Ben wrote: > Ah - I found out why I had cast it to a string. I had not, at that > point, worked out ho to pass the list by value rather than reference, > and so was casting to a string as a stopgap measure that I then forgot > about. Now the problem is fixed after this group told me how to pass a

Re: Bizzare lst length problem

2006-10-08 Thread Ben
Ah - I found out why I had cast it to a string. I had not, at that point, worked out ho to pass the list by value rather than reference, and so was casting to a string as a stopgap measure that I then forgot about. Now the problem is fixed after this group told me how to pass a list by value (by sl

Re: Bizzare lst length problem

2006-10-08 Thread John Machin
Theerasak Photha wrote: > On 8 Oct 2006 06:12:48 -0700, John Machin <[EMAIL PROTECTED]> wrote: > > > > > Show us the code that is creating instances of the panel class ... > > > > panel1 = > > panel(number=?,level=?,location=?,mops=,matrix=?) > > What are you passing as the 4th pos

Re: Bizzare lst length problem

2006-10-08 Thread Theerasak Photha
On 8 Oct 2006 06:12:48 -0700, John Machin <[EMAIL PROTECTED]> wrote: > > Show us the code that is creating instances of the panel class ... > > panel1 = > panel(number=?,level=?,location=?,mops=,matrix=?) > What are you passing as the 4th positional arg > ^^^ ??

Re: Bizzare lst length problem

2006-10-08 Thread Ben
Using Fredericks advice I managed to track down the problem - it was really very stupid. I had accidentally cast the list to a string earlier in another part of the code. Its a bit of an anticlimax really - not mysterious at all (just mysteriously remiss on my part) Apologies for not simple postin

Re: Bizzare lst length problem

2006-10-08 Thread John Machin
Ben wrote: > ...and when I print out the string, it is still formatted as one would > expect a list to be: > > "['01', '02', '03', '04']" > We know that. Fredrik deduced it and told you well over an hour ago. Show us the code that is creating instances of the panel class ... panel1 = panel(num

Re: Bizzare lst length problem

2006-10-08 Thread Ben
Thanks for the advice - I'm already doing just that, so hopefully will soon be sorted :-p John Machin wrote: > 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 instance

Re: Bizzare lst length problem

2006-10-08 Thread John Machin
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,mop

Re: Bizzare lst length problem

2006-10-08 Thread John Machin
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,mop

Re: Bizzare lst length problem

2006-10-08 Thread Ben
...and when I print out the string, it is still formatted as one would expect a list to be: "['01', '02', '03', '04']" 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 instan

Re: Bizzare lst length problem

2006-10-08 Thread Ben
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.numb

Re: Bizzare lst length problem

2006-10-08 Thread Fredrik Lundh
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 >

Bizzare lst length problem

2006-10-08 Thread Ben
Hello...hopefully my last question :-) I ave a dictionary, where each value is a class instance. I access it using: for k, v in self.panels.panel_list.items(): print "Number:\t",v.number print "Level:\t",v.level print "Location:\t",v.location