[issue9749] tuple-to-list conversion

Pyry Säilä report at bugs.python.org
Fri Sep 3 04:57:03 CEST 2010


New submission from Pyry Säilä <roadrunnahz at gmail.com>:

As I am new to Python and programming as a whole, I do not have extensive knowledge of how to correctly report a bug. And as such I must apologize for the inconvenience.

My lack of knowledge makes this only an assumption, but...

---

>>>l
[(1, 4, 7), (2, 5, 8), (3, 6, 9)]
>>>q = r = s = []
>>>for i in range(len(l)):
...    for x in l[i]:
...        q.append(x)
...    s = q
...    q = []
...    print s,    # print used to increase clarity
...    r.append(s)
...    print r    # and the next is printed out as:
...
[1, 4, 7] [1, 4, 7, [...]]
[2, 5, 8] [1, 4, 7, [...], [2, 5, 8]]
[3, 6, 9] [1, 4, 7, [...], [2, 5, 8], [3, 6, 9]]
>>>r
[1, 4, 7, [...], [2, 5, 8], [3, 6, 9]]
>>>r[3]    # for extra
[1, 4, 7, [...], [2, 5, 8], [3, 6, 9]]

---

Supposed outcome for r being [[1, 4, 7], [2, 5, 8], [3, 6, 9]]

----------
components: None
messages: 115413
nosy: Pyry.Säilä
priority: normal
severity: normal
status: open
title: tuple-to-list conversion
versions: Python 2.7, Python 3.1

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


More information about the Python-bugs-list mailing list