Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

List behaviour

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


gabe at dragffy

May 15, 2008, 3:08 AM

Post #1 of 1 (96 views)
Permalink
List behaviour

Hi all

Just wondering if someone could clarify this behaviour for me, please?

>>> tasks = [[]]*6
>>> tasks
[[], [], [], [], [], []]
>>> tasks[0].append(1)
>>> tasks
[[1], [1], [1], [1], [1], [1]]

Well what I was expecting to end up with was something like:
>>> tasks
[[1], [], [], [], [], []]


I got this example from page 38 of Beginning Python.

Regards

Gabriel



--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.