[New-bugs-announce] [issue20135] mutate list

Xiaoqing Rong report at bugs.python.org
Mon Jan 6 04:37:24 CET 2014


New submission from Xiaoqing Rong:

I was using IDLE (Python GUI) for Python 3.3.3. I don't know if this is a bug or you guys intend it to be this way:

>>> x=[1,2]
>>> y=x
>>> y.append(3)
>>> x
[1, 2, 3]

personally i'd prefer x stays as [1,2] when i'm trying to mutate y

also:
>>> def f1(m,n=['haha']):
	if m==n:
		print('m==n')
	else:
		print('m!=n')
	n.append('yaya')
	
>>> f1(['haha'])
m==n
>>> f1(['haha'])
m!=n

I'd prefer getting consistent results when calling functions like f1

----------
messages: 207410
nosy: m123orning
priority: normal
severity: normal
status: open
title: mutate list
type: behavior
versions: Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20135>
_______________________________________


More information about the New-bugs-announce mailing list