[Python-bugs-list] [ python-Bugs-500539 ] Inaccuracy(?) in tutorial section 9.2

noreply@sourceforge.net noreply@sourceforge.net
Tue, 08 Jan 2002 08:22:24 -0800


Bugs item #500539, was opened at 2002-01-07 12:15
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=500539&group_id=5470

Category: Documentation
Group: Not a Bug
Status: Closed
Resolution: Works For Me
Priority: 5
Submitted By: Andrew Koenig (arkoenig)
Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: Inaccuracy(?) in tutorial section 9.2

Initial Comment:
Section 9.2 paragraph 3 defines a namespace as a
mapping from names to objects.  Perhaps I'm being picky
here, but isn't a namespace a mapping from names to
object references?  For example, doesn't executing the
expression "modname.the_answer = 42" as shown in
paragraph 5 cause modname.the_answer to refer to a
different object than the one to which it referred
previously, rather than affecting the specific object
to which modname.the_answer refers?

----------------------------------------------------------------------

>Comment By: Andrew Koenig (arkoenig)
Date: 2002-01-08 08:22

Message:
Logged In: YES 
user_id=418174

Actually, I was saying the opposite.  Executing "x = 42"
certainly does not mutate the object that was previously
associated with x, but rather causes x to be associated with
a new object, namely 42.  To me that suggests that 42 is an
object and x is something else, perhaps a way of accessing
an object.

You are right that this kind of confusion is common among
people who write about C++, but you are not right that I
used C++ as the basis for my original comment.  I first
became aware of the importance of distinguishing between
objects and object references in Algol 68, many years before
C++ ever existed, and there is a wonderful piece in Lewis
Carroll's ``Through the Looking Glass'' about this very
issue.

More seriously, if there is no program I can ever write that
is capable of distinguishing between an object and an object
reference, then it doesn't matter.  However, I think I can
write such a program:

a = [42]; b = [a, a]

Now it doesn't make sense to say that b[0] and b[1] are the
same object, because they aren't.  Proof:  If I execute
b[0]=79, b[1] is still [42].  On the other hand, b[0] and
b[1] do refer to the same object, and it is that distinction
that I am suggesting that it is important to draw.

----------------------------------------------------------------------

Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2002-01-08 07:20

Message:
Logged In: YES 
user_id=3066

There is no difference between an object reference and an
object in Python code, so the statement in the tutorial is
correct.  The behavior you are describing as "object"
behavior seems to assume that there's some sort of
assignment  which mutates the object which is the current
value of the assignment target, but there is no such
operator.  I can see where this might be confusing for
programmers coming from C++, though.  ;-)

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=500539&group_id=5470