I think this is addressed somewhere in a python Gotchas list. These
lists're huge, but if you scan thru these every once in a while,
they're big timesavers:
http://www.ferg.org/projects/python_gotchas.html
http://zephyrfalcon.org/labs/python_pitfalls.html
http://zephyrfalcon.org/labs/beginners_mi
yes,
thank you for your help
--
http://mail.python.org/mailman/listinfo/python-list
"Meo" <[EMAIL PROTECTED]> writes:
> Somebody understand what's going on here?
Yes, []*3 gives you three references to the same empty list, not three
separate empty lists. You need something like
[[] for i in xrange(3)]
to get separate lists.
Another example:
a = [1,2,3]
b = a
a
Hi,
Here is what I'm doing in python 2.4.1 :
>>> aOfa=[[[]]*3]*4
>>> aOfa
[[[], [], []], [[], [], []], [[], [], []], [[], [], []]]
>>> aOfa[3][2].append(1)
>>> aOfa
[[[1], [1], [1]], [[1], [1], [1]], [[1], [1], [1]], [[1], [1], [1]]]
Ok, so there is something I didn't understand about python's a