binding a reference to a variable
Aahz
aahz at pythoncraft.com
Wed Apr 10 15:53:04 EDT 2002
In article <yu99pu18lai2.fsf at europa.research.att.com>,
Andrew Koenig <ark at research.att.com> wrote:
>>> Now, f is an object that I can use to rebind the name x. For
>>> example, if I execute f(42), that sets x to 42.
>
>Aahz> You really don't want to do this in Python.
>
>One thing that fascinates me is how the nature of a language affects
>the preferred idioms therein. To help me further my understanding,
>would you mind explaining to me why this particular idea is undesirable
>in Python? I can think of several possible reasons, but I don't know
>which reason is most plausible to the Python community.
You've already gotten a couple of answers; from my perspective, the best
I can say is that is that Python supports mutable objects but not
mutable names. I think you know Python well enough to understand what I
mean, but if it's not clear, I'll try expanding it.
To repeat some other posts, give us more context for what you're trying
to do, and we'll see if we can come up with Pythonic idioms for it.
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"There are times when effort is important and necessary, but this should
not be taken as any kind of moral imperative." --jdecker
More information about the Python-list
mailing list