Python dumps core with this.. how come?

Dennis Lee Bieber wlfraed at ix.netcom.com
Sat Jan 22 15:42:33 EST 2000


On Sat, 22 Jan 2000 16:45:06 +0100, "Fredrik Lundh"
<fredrik at pythonware.com> declaimed the following in comp.lang.python:

> 
> 5. simple assignments don't copy any data,
>    they rebind the name
> 
> (here, a simple assignment is an assignment
> of the form "name = expression".  more com-

	This was something that took me a few minutes to understand when
I first encountered it myself.

	I finally had to resort to the old "intro to computing 101"
mailbox simile.

	The traditional example is a set of mailboxes each with a name
on the front. A statement of the form "A = <constant>" was represented
by taking out whatever paper was in the box named "A", and putting in a
paper with <constant> on it. "A = <variable name>" meant making a copy
of the paper in the box named <variable name> and putting that copy into
the "A" box.

	Python seems to reverse this.

	"A = <constant>" looks for the box with the name "A" on it (if
it exists), removes the name-label, and then sticks the label on
whatever box contains the paper with <constant>. Same for "A = <variable
name>" -- The box with the name "A" on it is moved to whichever box
already has the label <variable name>. Potentially, this can leave a box
with no labels attached (ready to be garbage collected), and does leave
the other box with more than one label.
--
 > ============================================================== <
 >   wlfraed at ix.netcom.com  | Wulfraed  Dennis Lee Bieber  KD6MOG <
 >      wulfraed at dm.net     |       Bestiaria Support Staff       <
 > ============================================================== <
 >        Bestiaria Home Page: http://www.beastie.dm.net/         <
 >            Home Page: http://www.dm.net/~wulfraed/             <



More information about the Python-list mailing list