Message590
###
### list() in CPython
###
[localhost:~] dinu% python
Python 2.2 (#1, Feb 13 2002, 11:18:45)
[GCC 2.95.2 19991024 (release)] on darwin
Type "help", "copyright", "credits" or "license" for
more information.
>>>
>>> L = [1, 2, 3]
>>> L2 = list(L)
>>> L2
[1, 2, 3]
>>> L2.insert(0, 4)
>>> L2
[4, 1, 2, 3]
>>> L
[1, 2, 3] ### as expected, same on CPython 2.1
###
### list() in Jython
###
[localhost:~] dinu% jython
Jython 2.1 on java1.3.1 (JIT: null)
Type "copyright", "credits" or "license" for more
information.
>>>
>>> L = [1, 2, 3]
>>> L2 = list(L)
>>> L2
[1, 2, 3]
>>> L2.insert(0, 4)
>>> L2
[4, 1, 2, 3]
>>> L
[4, 1, 2, 3] ### unexpected
>>>
>>>
>>> import copy
>>> L = [1, 2, 3]
>>> L3 = copy.copy(L) # instead of list() (use only
for this snippet)
>>> L3.insert(0, 4)
>>> L3
[4, 1, 2, 3]
>>> L
[1, 2, 3] ### as expected
|
|
Date |
User |
Action |
Args |
2008-02-20 17:17:02 | admin | link | issue522558 messages |
2008-02-20 17:17:02 | admin | create | |
|