how can I get the name of a variable (or other object)?
JCM
joshway_without_spam at myway.com
Thu Jul 22 13:39:15 EDT 2004
Grant Edwards <grante at visi.com> wrote:
...
>> 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 consider the values to be references to objects. But as you say...
> 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.
It's really just about terminology. Personally I'd find it confusing
if I were new to Python and heard someone say that Python has
bindings-of-some-sort, but not variables. My background is compilers
and programming language semantics, so maybe I'm also just being
overly pedantic.
More information about the Python-list
mailing list