Loris Caren a écrit : > 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.
for obj in (a, b, c):
if obj == 'cabbage':
obj = 'coconut'
--
http://mail.python.org/mailman/listinfo/python-list
