>>> a = [1,2,3]
>>> b = [0,a,4]
>>> b
[0, [1, 2, 3], 4]
>>> b[1][1] = 0
>>> b
[0, [1, 0, 3], 4]
>>> a
[1, 0, 3]
( Or try "a = [0, a, 4]" for a nice circular reference! )
And thus the difference between:
>>>c = b # "renaming" a list, or copying a reference, and
>>>c = b[:] # copying a list.
Now what I need to do is represent subsets of a sequence as a
sequence. But the sequence elements will each be rather large
text strings ( or tuple of strings. ). I assume the obvious:
sublist = [ list[0], list[4], list[22], ... list[98] ]
since it is using the values of the list, will create redundant
copies of the elements. I suppose what I need to do is create
a class wrapper ( here we go! another pseudo-sequence class! :-)
around a representation of:
MyClass.elems = [ (list,0), (list,4), (list,22), ... (list,98) ]
and an appropriate __getitem__, etc. to translate MyClass[2] into
MyClass.elem[2][0][MyClass.elem[2][1]].
However, if "list" is modified, then the indirect references of
( list, index ) become all wrong !!!
Does anyone else have any solutions or suggestions to this problem ?
I suppose I could introduce another level of indirection: create a
python version of lisp 'gensym' to create uniq names, and store and
eval those namestrings. (? does that make any sense? ) Is there some
way I can use 'id' for this sort of reference ? ( I know I can
use 'id' or 'hash' to make the symbol names --- I mean is there
any way I can reference something FROM it's id ? )
- Steve Majewski (804-982-0831) <sdm7g@Virginia.EDU>
- UVA Department of Molecular Physiology and Biological Physics
*Special Python (Monty) addendum: There was a NPR interview, about a
week ago, with the members of Firesign Theatre, where they paid homage
to their inspirations and ancestors - Stan Freeburg and the BBC Goon
Show. I mention this because I know the Goon Show was a particular
influence on the members of Monty Python. ( and probably all British
comedy of that generation! ) I am a particular fan of Spike Milligan:
I used to have a copy of his book "Hitler: My part in his downfall".
Does anyone happen to know if his books are still in print, or know
the titles of his other books ?