Jason Scheirer [EMAIL PROTECTED] writes:
On Nov 24, 10:34 pm, [EMAIL PROTECTED] wrote:
Hi Python experts! Please explain this behavior:
nn=3*[[]]
nn
[[], [], []]
mm=[[],[],[]]
mm
[[], [], []]
Up till now, 'mm' and 'nn' look the same, right? Nope!
mm[1].append(17)
mm
[[],
On Tue, Nov 25, 2008 at 9:23 AM, Arnaud Delobelle [EMAIL PROTECTED]wrote:
Jason Scheirer [EMAIL PROTECTED] writes:
On Nov 24, 10:34 pm, [EMAIL PROTECTED] wrote:
Hi Python experts! Please explain this behavior:
nn=3*[[]]
nn
[[], [], []]
mm=[[],[],[]]
mm
[[], [], []]
Arnaud Delobelle wrote:
Jason Scheirer [EMAIL PROTECTED] writes:
On Nov 24, 10:34 pm, [EMAIL PROTECTED] wrote:
Hi Python experts! Please explain this behavior:
nn=3*[[]]
nn
[[], [], []]
mm=[[],[],[]]
mm
[[], [], []]
Up till now, 'mm' and 'nn' look the same, right? Nope!
The issue is exhausted in Python Library Reference, Chapter 3.6, so I
should apologize for initial posting. All comments were helpful,
though Arnaud and Steve are right that pass-by-anything is off the
point.
Thanks All!
--
http://mail.python.org/mailman/listinfo/python-list
Steve Holden [EMAIL PROTECTED] writes:
Arnaud Delobelle wrote:
Jason Scheirer [EMAIL PROTECTED] writes:
Python is pass-by-reference, not pass-by-value.
It's certainly not pass-by-reference, nor is it pass-by-value IMHO.
Since no lists are being passed as arguments in these examples it's
Hi Python experts! Please explain this behavior:
nn=3*[[]]
nn
[[], [], []]
mm=[[],[],[]]
mm
[[], [], []]
Up till now, 'mm' and 'nn' look the same, right? Nope!
mm[1].append(17)
mm
[[], [17], []]
nn[1].append(17)
nn
[[17], [17], [17]]
???
Python 2.5 Win XP
Thanks!
--
[EMAIL PROTECTED] wrote:
Hi Python experts! Please explain this behavior:
[] make an empty list.
[ [],[],[] ] makes a list of three different empty lists.
3*[[]] makes a list of three references to the same list.
Realy, that should explain it all, but perhaps there are enough empty
lists
On Nov 24, 10:34 pm, [EMAIL PROTECTED] wrote:
Hi Python experts! Please explain this behavior:
nn=3*[[]]
nn
[[], [], []]
mm=[[],[],[]]
mm
[[], [], []]
Up till now, 'mm' and 'nn' look the same, right? Nope!
mm[1].append(17)
mm
[[], [17], []]
nn[1].append(17)
nn
[[17],