Re: [Tutor] Issue with iterating within lists, objects and functions

2007-08-03 Thread Kent Johnson
Ricardo Aráoz wrote: > Kent Johnson wrote: >> Andy Cheesman wrote: >>> for thing in ["top", "right", "bottom", "left"]: >>> eval("self." + thing).append("fish") >> You don't need to use eval() here, use getattr() instead: >> getattr(self, thing).append('fish') >> > > What if you want to do : >

Re: [Tutor] Issue with iterating within lists, objects and functions

2007-08-03 Thread Andy Cheesman
Thanks for your help Kent The error was that I was trying to assign to a non-assignable reference as you highlighted. Everything works now Thanks Andy Kent Johnson wrote: > Andy Cheesman wrote: >> for thing in ["top", "right", "bottom", "left"]: >> eval("self." + thing).append("fish") > >

Re: [Tutor] Issue with iterating within lists, objects and functions

2007-08-03 Thread Kent Johnson
Andy Cheesman wrote: > for thing in ["top", "right", "bottom", "left"]: > eval("self." + thing).append("fish") You don't need to use eval() here, use getattr() instead: getattr(self, thing).append('fish') > eval("self." + thing +"_extra") > eval("self." + thing) = external_funct