Socket connection

Grant Edwards grante at
Fri Mar 7 18:04:56 CET 2003

In article <b4ac61$ngl$1 at>, sik0fewl wrote:

> I had no idea that x = y just references y to x

Not really.

The assignment statement 

  x = y

Causes the name "x" to be bound to whatever object the name "y"
is currently bound to. In this usage, "bound to" means the same
thin as "references" in your posting.

> (when x & y are lists).

When x and y are anything.

  x = []
That creates a list object and points the name "x" at it:

             "x"  -->  <list object>
Then the assignment

  y = x
Points the name "y" at the same object:

             "x" -->
                      <list object>
             "y" -->

The important thing is to realize that when you do 

  x = []

That doesn't make "x" a list.  "x" is just a name in a
namespace.  The actual list is an independant object that lives
off in some undefined place.

The assignment creates a name "x" and makes it reference that

The list object doesn't even _know_ that it is pointed to by
the name "x" in some namespace or other. [Unless you want to
talk about reference counted garbage collection.  Then the list
knows that it is indeed pointed to, but that's an
under-the-covers implimentation mechanism that isn't part of
the language definition.]

Grant Edwards                   grante             Yow!  NOT fucking!! Also
                                  at               not a PACKAGE of LOOSE-LEAF

More information about the Python-list mailing list