Modifying Class Object
steven at REMOVE.THIS.cybersource.com.au
Thu Feb 11 06:46:27 CET 2010
On Wed, 10 Feb 2010 23:56:36 +0100, Alf P. Steinbach wrote:
> * Steven D'Aprano:
>> On Wed, 10 Feb 2010 21:02:14 +0100, Alf P. Steinbach wrote:
>>> "pointer" refers to a copyable reference value as seen from the Python
>>> level, in the same way as "pointer" is used by e.g. the Java language
>> Python doesn't have "copyable reference values" in the Python level. It
>> has objects.
> s = 
> t = s # Copies reference.
> t = 2 # Changes referenced object via copied reference.
> print( s ) # Checks the object via the original reference.
> your argument that the copied reference does not exist, is just silly.
> And you know it.
You keep making a habit of pretending that you know what other people are
thinking, accusing them of lying for having an opinion that differs from
yours, and of deliberately making silly arguments that the poster (in
this case, me) knows is untrue. It is an obnoxious, trolling habit.
Please stop it.
I don't "know" it is a silly argument, because I don't accept your
s = 
t = s # Binds the name t to the object bound to the name s.
t = 2 # Changes the object bound to the name t
print(s) # Checks the object via the original name.
Notice that your version describes what happens according to some
implementation, below the level of the Python virtual machine. My version
describes what happens at the level of high-level Python code, which is
the defined semantics of the language. It makes no assumptions about the
implementation, completely unlike yours which is entirely implementation-
specific. My description is equally valid whether Python is being
executed by the CPython virtual machine on an Intel-compatible processor,
or hand-simulated with pencil and paper, or something completely
different. Yours is not.
I describe the high-level language, you describe one implementation.
Neither view is *wrong*, per se, but one describes the semantics of the
language while the other describes the implementation.
The first paragraph of the Python docs about the execution model says:
"NAMES REFER TO OBJECTS [emphasis added]. Names are introduced by name
binding operations. Each occurrence of a name in the program text refers
to the binding of that name established in the innermost function block
containing the use."
Apart from the use of the generic English term "refers to" (and similar),
you will find *nothing* about pointers in this. That's because pointers
are not a part of the high-level behaviour of Python.
where you will also not find the word "pointer" used to describe any high-
level Python feature, or used in relation to assignment.
More information about the Python-list