Python IRC dictatorship

holger krekel pyth at devel.trillke.net
Sat Nov 23 12:16:48 EST 2002


John Hunter wrote:
> >>>>> "Timothy" == Timothy Rue <threeseas at earthlink.net> writes:
> [...]
> "variables" in python are a little different than in other programming
> languages.  python has "names" for objects.  This example illustrates
> one of the initially surprising ways names work
> 
>   x = []
>   y = []

of course you mean

    x = y = []

>   x.append(1)
>   print y
> 
> x and y are just names for the same object (the empty list).  When you
> change that object referring to it by the name 'x', the changes are
> seen when you refer to it by it's other name 'y'.  So y now equals
> [1].

regards,

    holger




More information about the Python-list mailing list