Modifying Class Object
Alf P. Steinbach
alfps at start.no
Tue Feb 9 00:12:07 EST 2010
* Terry Reedy:
> On 2/8/2010 2:10 PM, Alf P. Steinbach wrote:
>
>> I apologize for assuming that "pointer" is a known word to [c.l.p.]
>> denizens.
>
> It is irrelevant.
>
> Python calls Python functions by associating argument objects (or
> objects derived therefrom) with paramenter names, very much like
> assigment statements.
Well, part of the above is word-play. When a name refers to an object elsewhere
and that reference can be copied around, then it is a pointer to the object in
e.g. the Java sense, which I very purposefully referenced to be clear about it.
So you're saying that X is irrelevant in Python because Python uses Y, where Y
is a description of X...
But part of what you write puzzles me.
As far as the language spec is concerned the argument passing mechanism seems to
me to be identical to assignments, not just "very much like".
Your phrase "or objects derived therefrom" seems to imply that immutable objects
can be copied (an optimization that once was rejected), but as far as I can see
the language spec only talks about binding with no provision for binding to do
anything else than making a name refer directly to a specified object,
presumably with *the same id*.
Not talking about things built on top of argument passing like *, and not
talking about scopes or other (in this context) extraneous details: is there
something I've overlooked in the basic mechanism?
> If one understands Python objects, names, and assignment statements,
> which one must to understand Python, this completely explains the
> function calls, function execution, and its effect on passed objects.
Yes.
There are many ways to understand it though.
The simplest description, reality, that names refer to objects, where those
references can be copied, i.e. that they in e.g. the Java sense are pointers to
objects, seems to be simplest -- and is certainly shortest. :-)
> All Python expressions evaluate to an object. Call expressions evaluate
> to the object returned by the function.
>
> Different interpreters implement call and return differently. Certainly,
> most humans do not use C pointers when they mentally execute Python code.
The Java language spec reference for "pointer" was to avoid arguments about
irrelevant specialized meanings of the term, such as C pointers.
Cheers & hth.,
- Alf
More information about the Python-list
mailing list