You can do an insertion into a Python list with the "slice" operator:
( But I don't know if this is what you mean. )
>>> a = [ 1, 2, 3, 4 ]
>>> a
[1, 2, 3, 4]
>>> a[2:3]
[3]
>>> a[2:3] = [3,2,1,2,3]
>>> a
[1, 2, 3, 2, 1, 2, 3, 4]
>>>
Python does not have pointers, but references to mutable objects
ARE references to the OBJECT, and not the VALUE.
>>> b = [ a, 'test', a ]
>>> b
[[1, 2, 3, 2, 1, 2, 3, 4], 'test', [1, 2, 3, 2, 1, 2, 3, 4]]
>>> a[3:]
[2, 1, 2, 3, 4]
>>> del a[3:] # truncate 'a'
>>> a
[1, 2, 3]
>>> b
[[1, 2, 3], 'test', [1, 2, 3]] # b = [a, 'test', a] 's "a" is truncated
>>> a = 'xxx' # this binds the NAME "a" to a new value
>>> b # and doesn't affect b's copy of the OBJECT 'a'
[[1, 2, 3], 'test', [1, 2, 3]] # which exists as long as there are references
>>>
- Steve Majewski (804-982-0831) <sdm7g@Virginia.EDU>
- UVA Department of Molecular Physiology and Biological Physics