On Nov 7, 2012 3:55 PM, "Ethan Furman" <et...@stoneleaf.us> wrote: > > Oscar Benjamin wrote: >> >> A more modest addition for the limited case described in this thread could be to use exponentiation: >> >> >>> [0] ** (2, 3) >> [[0, 0, 0], [0, 0, 0]] > > > What would happen with > > --> [{}] ** (2, 3)
The list being exponentiated does nothing with its elements. The exponentiation just tells it to create a list of distinct lists. In this case each element of each sublist is the same dict. However if you assign to an element of the sublist (rather than into the dict) it replaces the dict in that sublist and not the others. > > or > > --> [my_custom_container()] ** (2, 3) Ditto Oscar
-- http://mail.python.org/mailman/listinfo/python-list