Re: Help with dynamic attributes.

2006-01-09 Thread Mike Meyer
"Mr.Rech" <[EMAIL PROTECTED]> writes: > Hi all, > I was writing a simple class when I get a strange error message that I > can't > understand. Hopefully someone could help me here. > > My class's init method takes a list of lists as input argument and I'd > like to create > several attributes each

Re: Help with dynamic attributes.

2006-01-09 Thread Bruno Desthuilliers
Mr.Rech a écrit : (snip) > > My class's init method takes a list of lists as input argument and I'd > like to create > several attributes each one referencing one item of the passed list. > > Easy-of-use arguments > has led me to call these attributes as x0, x1, x2 and so on. This is a very wro

Re: Help with dynamic attributes.

2006-01-09 Thread Mr.Rech
I would have sworn that it had been a better way to get it. Thanks a lot, Andrea -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with dynamic attributes.

2006-01-09 Thread Fredrik Lundh
"Mr.Rech" wrote: > class foo(object): >def __init__(self, list_of_lists): >self.lol = list(list_of_lists) > >for i in range(len(list_of_lists)): >exec 'self.x%d = self.lol[%d]' % (i, i) > >self.shape = tuple(len(item) for item in self.lol) generator express

Help with dynamic attributes.

2006-01-09 Thread Mr.Rech
Hi all, I was writing a simple class when I get a strange error message that I can't understand. Hopefully someone could help me here. My class's init method takes a list of lists as input argument and I'd like to create several attributes each one referencing one item of the passed list. Easy-of-