As an example:
a = TkList(['spam', 'camembert', 'camelot'])
a.pack()
a = a + [{'guido':'god'}] # e.g. you can store any object
a.append([Tkinter.Button]) # not a mistake - it uses str() for display,
a = a*2 # also not a mistake, although not very useful =)
a = a[:-2]
a.sort()
a.reverse()
I've also included demo code at the end of the module, but note that
it requires another file, TkUtil.py, available in the same place.
http://maigret.cog.brown.edu/python/Tk/TkList.py
--
Brown University Box 1978 Providence RI 02912
Department of Cognitive and Linguistic Sciences
David_...@Brown.EDU (401) 863-3926
Cool!
> a = a + [{'guido':'god'}] # e.g. you can store any object
> a = a*2 # also not a mistake, although not very useful =)
> a = a[:-2]
I'm not sure these operations should be implemented. For most other
sequence types, these three operations (+, * and [:]) yield *new*
objects without changing their operands. You make them modify the
first operands. What if someone generalizes and does something like
b = a[:2]
and assumes that this somehow creates a new list?
Or what if I write
b = a + b
???
Operations that modify their argument in this fashion are better
expressed as methods, similar to append(), sort() and reverse().
--Guido van Rossum <gu...@CNRI.Reston.VA.US>
URL: <http://www.python.org/~guido/>