tutor-request:
I found this interesting question in a local forum,
and want to get a more detail explain of it:
>>> a = [[]]*5
>>> a
[[], [], [], [], []]
>>> a[0].append(3)
>>> a
[[3], [3], [3], [3], [3]]
>>> b = [[] for i in range(5)]
>>> b
[[], [], [], [], []]
>>> b[0].append(3)
>>> b
[[3], [], [], [], []]
This look something like pointer! I found it also work for tuple !
>>> l1=((1,2),(2,3))*5
>>> l1
((1, 2), (2, 3), (1, 2), (2, 3), (1, 2), (2, 3), (1, 2), (2, 3), (1, 2), (2, 3))
So, can somebody tell me how the * operator of list and tuple work,
and how can we make use of it?
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Yang
[EMAIL PROTECTED]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡2007-08-02
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor