Why does changing 1 list affect the other?
Peter Otten
__peter__ at web.de
Fri Nov 7 03:02:07 EST 2003
More information about the Python-list mailing list
Fri Nov 7 03:02:07 EST 2003
- Previous message (by thread): Why does changing 1 list affect the other?
- Next message (by thread): Why does changing 1 list affect the other?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Cy Edmunds wrote: > Try this: > >>>> x = 5 >>>> y = x >>>> print x is y > True > > y is second reference to the immutable value 5, not a copy. As an aside, you cannot reliably test Python's general behaviour for immutable types with small integers (-5 <= i <= 99), as every literal in this range will refer to the same instance: >>> x = 5 >>> y = 5 >>> x is y True But: >>> x = 100 >>> y = 100 >>> x is y False Peter
- Previous message (by thread): Why does changing 1 list affect the other?
- Next message (by thread): Why does changing 1 list affect the other?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list