Re: assignment to reference

2005-10-27 Thread Sybren Stuvel
Bruno Desthuilliers enlightened us with: for obj in (a, b, c): if obj == 'cabbage': obj = 'coconut' Doesn't work on my Python: Python 2.4.2 (#2, Sep 30 2005, 21:19:01) [GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu8)] on linux2 Type help, copyright, credits or license for

Re: assignment to reference

2005-10-27 Thread Loris Caren
Thank you all for your replies. They have helped me understand that immutable means just that! Blame my c heritage where a pointer allows you to scribble over anything. -- http://mail.python.org/mailman/listinfo/python-list

assignment to reference

2005-10-26 Thread Loris Caren
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

Re: assignment to reference

2005-10-26 Thread Sybren Stuvel
Loris Caren enlightened us with: 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

Re: assignment to reference

2005-10-26 Thread Fredrik Lundh
Loris Caren wrote: 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? if you need a

Re: assignment to reference

2005-10-26 Thread Bruno Desthuilliers
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?

Re: assignment to reference

2005-10-26 Thread Michael Tobis
I apparently don't understand this question in the same way the way others do. I think the question is about the mutability of strings. To my understanding of your question, it is impossible, at least if the referenced objects are strings or other objects of immutable type. 'cabbage' cannot be