assignment to reference
bdesth.quelquechose at free.quelquepart.fr
Wed Oct 26 23:26:17 CEST 2005
Loris Caren a écrit :
> a = 'apple'
> b = 'banana'
> c = 'cabbage'
> How can I get something like:-
> for i in 'abc':
> r = eval(i)
> if r == 'cabbage': r = 'coconut'
> actually change the object referenced by r rather
> than creating a new object temporarily referenced by it?
> I've tried playing with eval and exec without the desired
for obj in (a, b, c):
if obj == 'cabbage':
obj = 'coconut'
More information about the Python-list