how can I get the name of a variable (or other object)?
Grant Edwards
grante at visi.com
Thu Jul 22 13:29:20 EDT 2004
On 2004-07-22, JCM <joshway_without_spam at myway.com> wrote:
> Grant Edwards <grante at visi.com> wrote:
> ...
>> Python doesn't have variables. Python has objects. Python
>> has dictionaries that map strings (names) to objects. In your
>> example above, there is an integer object with a value of 33.
>
> The Python documentation talks about variables. Personally I
> think that's a fine name for the scoped binding between an
> identifier and a value.
But it's not a binding between an identifier and a value. It's
a binding between an identifier and an _object_. For immutable
objects, it's a moot point, but for mutable objects, there are
some real-world programming consequences.
I think it's very confusing to people who were taught that a
variable is a named region of storage in which a value
(possibley of one specific type) could be stored. I think that
referring to a Python name/object pair as "a variable" is
perpetuating a fundamental misunderstanding of what's really
going on.
If we want to refer to Python "variables" then I think the
"value" of a "variable" should be always be referred to as "a
pointer to an object".
I'm probably being overly pedantic, but I've seen a lot of
confusing amongst new Python programs due to their view of
python name bindings as "variables" in the traditional sense of
the word.
--
Grant Edwards grante Yow! This is my WILLIAM
at BENDIX memorial CORNER
visi.com where I worship William
Bendix like a GOD!!
More information about the Python-list
mailing list