[New-bugs-announce] [issue8081] a.append appends reference , causing unexpected behaviour
hamish farrant
report at bugs.python.org
Sat Mar 6 23:26:16 CET 2010
New submission from hamish farrant <farrantino at gmail.com>:
Causes modification of an list object to change the values of the object already inside the list.
Example code :
import random
a =[]
b = [1 , 2 , 3 , 4]
for i in range (15):
random.shuffle(b)
a.append(b)
for j in a:
print j
Expected Behaviour : the list referenced by b , should be appended to a , creating a list of random permutations of b.
----------
components: Interpreter Core
messages: 100548
nosy: hamish.farrant
severity: normal
status: open
title: a.append appends reference , causing unexpected behaviour
type: behavior
versions: Python 2.6
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8081>
_______________________________________
More information about the New-bugs-announce
mailing list