assignment to reference

Loris Caren loris at caren.demon.co.uk
Wed Oct 26 06:13:07 EDT 2005


If

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
effect.



More information about the Python-list mailing list