Return value of an assignment statement?
Aahz
aahz at pythoncraft.com
Fri Feb 22 14:05:31 EST 2008
In article <AcWdnVgsAZnOwCPanZ2dnUVZ_oTinZ2d at comcast.com>,
Jeff Schwab <jeff at schwabcenter.com> wrote:
>Aahz wrote:
>> In article <5MSdncSVGdGriCPanZ2dnUVZ_vPinZ2d at comcast.com>,
>> Jeff Schwab <jeff at schwabcenter.com> wrote:
>>> bruno.desthuilliers at gmail.com wrote:
>>>>
>>>> There's nothing like a variable "storing" anything in Python. All you
>>>> have are names to (references to) objects binding in a namespace. Now
>>>> the fact is that some types are mutable and other are not. In your
>>>> above example, the augmented assignment does *not* rebind a, but
>>>> invoke a.extend(). With integers, it would have rebind a. So while
>>>> your observation is exact, your interpretation is wrong !-)
>>> Thank you for the clarification. For some reason, I had it in my head
>>> that ints were packed directly into the C structures that represent
>>> Python variables, in the same (union?) member that otherwise would store
>>> a pointer.
>>
>> Notice very very carefully that Bruno is not using "variable". Many
>> expert Python programmers strongly prefer to talk about "names" instead
>> of "variables" (especially when explaining the Python object model)
>> precisely because using "variable" leads to incorrect expectations.
>>
>> http://starship.python.net/crew/mwh/hacks/objectthink.html
>
>So what is the "variable?" Or is Python the first HLL I've ever heard
>of that didn't have variables?
Whether Python has "variables" depends on your perspective. Python
certainly does *not* have variables with anything like the semantics of
C/C++ variables. For that reason, it's often convenient to shift the
vocabulary to avoid misunderstading. However, the vast majority of
Python programmers do use "variable" in casual conversation (I certainly
do); it's only when trying to discuss the Python object model that
there's a strong tendency to switch to using "names".
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"All problems in computer science can be solved by another level of
indirection." --Butler Lampson
More information about the Python-list
mailing list