Nested function scope problem
Gerhard Fiedler
gelists at gmail.com
Thu Jul 27 10:47:18 EDT 2006
On 2006-07-27 09:42:16, Bruno Desthuilliers wrote:
>> Are you saying Python variables don't hold references to "actual" Python
>> objects?
>
> Exactly.
>
>> That idea has been working well for me so far.
>
> It can only take you so far. Now it's time you know the truth: there are
> *no* 'variables' in Python (hence the term 'binding').
>
> What you really have is (somewhat simplified, of course) a dict with
> names as keys and objects references (think of 'smart' pointers) as
> values. So the name doesn't 'hold' anything - it's really nothing more
> than a name. And the object doesn't know nothing about which names it's
> bound to.
I see that, and this thread and your and others explanations have been
helpful in seeing deeper.
But can't this be expressed -- maybe -- as the variable name "holding" the
reference that is associated to it through the dict? Aside the explicit
mentioning of the dict (which I agree is in itself a value, especially
since that dict exists and can be accessed as dict), the image seems to
provide the same analogy.
Gerhard
More information about the Python-list
mailing list