Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tuple-to-list conversion #53958

Closed
pyrysaila mannequin opened this issue Sep 3, 2010 · 3 comments
Closed

tuple-to-list conversion #53958

pyrysaila mannequin opened this issue Sep 3, 2010 · 3 comments

Comments

@pyrysaila
Copy link
Mannequin

pyrysaila mannequin commented Sep 3, 2010

BPO 9749
Nosy @rhettinger

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2010-09-03.04:39:15.998>
created_at = <Date 2010-09-03.02:57:01.498>
labels = ['invalid']
title = 'tuple-to-list conversion'
updated_at = <Date 2010-09-03.07:15:12.040>
user = 'https://bugs.python.org/pyrysaila'

bugs.python.org fields:

activity = <Date 2010-09-03.07:15:12.040>
actor = 'pyry.saila'
assignee = 'none'
closed = True
closed_date = <Date 2010-09-03.04:39:15.998>
closer = 'rhettinger'
components = []
creation = <Date 2010-09-03.02:57:01.498>
creator = 'pyry.saila'
dependencies = []
files = []
hgrepos = []
issue_num = 9749
keywords = []
message_count = 3.0
messages = ['115413', '115418', '115422']
nosy_count = 2.0
nosy_names = ['rhettinger', 'pyry.saila']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue9749'
versions = ['Python 3.1', 'Python 2.7']

@pyrysaila
Copy link
Mannequin Author

pyrysaila mannequin commented Sep 3, 2010

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]]

@rhettinger
Copy link
Contributor

Sorry, this isn't a bug. I think you've rediscovered a property of mutable objects. See http://docs.python.org/tutorial/controlflow.html#default-argument-values for an example.

@pyrysaila
Copy link
Mannequin Author

pyrysaila mannequin commented Sep 3, 2010

Ah, I see. What a stupid error. My apologies.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant