Re: loop over list and modify in place

2006-09-30 Thread Paul Rubin
"Daniel Nogradi" <[EMAIL PROTECTED]> writes: > Is looping over a list of objects and modifying (adding an attribute > to) each item only possible like this? > > mylist = [ obj1, obj2, obj3 ] > > for i in xrange( len( mylist ) ): > mylist[i].newattribute = 'new value' for m in mylist: m.ne

Re: loop over list and modify in place

2006-09-30 Thread Daniel Nogradi
> Call me crazy, but isn't the simple construct > for obj in mylist: > obj.newattribute = 'new value' > what the OP was looking for? Yes, of course. That's why my follow-up post was this: > Please consider the previous question as an arbitrary random brain > cell fluctuation whose pro

Re: loop over list and modify in place

2006-09-30 Thread James Stroud
John Machin wrote: > James Stroud wrote: > >>Daniel Nogradi wrote: >> >>>Is looping over a list of objects and modifying (adding an attribute >>>to) each item only possible like this? >>> >>>mylist = [ obj1, obj2, obj3 ] >>> >>>for i in xrange( len( mylist ) ): >>> mylist[i].newattribute = 'new

Re: loop over list and modify in place

2006-09-30 Thread John Machin
James Stroud wrote: > Daniel Nogradi wrote: > > Is looping over a list of objects and modifying (adding an attribute > > to) each item only possible like this? > > > > mylist = [ obj1, obj2, obj3 ] > > > > for i in xrange( len( mylist ) ): > >mylist[i].newattribute = 'new value' > > > > > > I'

Re: loop over list and modify in place

2006-09-30 Thread James Stroud
Daniel Nogradi wrote: > Is looping over a list of objects and modifying (adding an attribute > to) each item only possible like this? > > mylist = [ obj1, obj2, obj3 ] > > for i in xrange( len( mylist ) ): >mylist[i].newattribute = 'new value' > > > I'm guessing there is a way to do this wi

Re: loop over list and modify in place

2006-09-30 Thread Daniel Nogradi
> Is looping over a list of objects and modifying (adding an attribute > to) each item only possible like this? > > mylist = [ obj1, obj2, obj3 ] > > for i in xrange( len( mylist ) ): > mylist[i].newattribute = 'new value' > > > I'm guessing there is a way to do this without introducing the (in

loop over list and modify in place

2006-09-30 Thread Daniel Nogradi
Is looping over a list of objects and modifying (adding an attribute to) each item only possible like this? mylist = [ obj1, obj2, obj3 ] for i in xrange( len( mylist ) ): mylist[i].newattribute = 'new value' I'm guessing there is a way to do this without introducing the (in principle unnec