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 :
>
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")
>
>
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