>>> x=[[0]*2]*2

This replicates the references.  It doesn't copy objects.

This short transcript demonstrates that concept:

    >>> x = [[0, 0], [0, 0]]
    >>> map(id, x)
    [16988720, 16988160]
    >>> y = [[0]*2]*2
    >>> y
    [[0, 0], [0, 0]]
    >>> map(id, y)
    [16988520, 16988520]

The object x refers to is a list with references to two other lists.  The
object y refers to is a list with two references to the same list.

Skip
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to