Tuple assignment and generators?

Fredrik Lundh fredrik at pythonware.com
Fri May 5 11:50:39 CEST 2006

"vdrab" wrote:

> Does the documentation mention that "x is y" returns True when they are
> both 0 but not when they are 100001 ?

language reference, comparisions (is operator):

    The operators is and is not test for object identity: x is y is true if and
    only if x and y are the same object

language reference, objects:

    "Even the importance of object identity is affected in some sense: for
    immutable types, operations that compute new values may actually
    return a reference to any existing object with the same type and value,
    while for mutable objects this is not allowed. E.g., after "a = 1; b = 1",
    a and b may or may not refer to the same object with the value one,
    depending on the implementation, but after "c = []; d = []", c and d are
    guaranteed to refer to two different, unique, newly created empty lists.

(note the use of "may or may not" and "depending on the implementation")


More information about the Python-list mailing list