It's still I, Miville
Erik Max Francis
max at alcyone.com
Sun Nov 2 00:18:44 EST 2003
François Miville-Dechêne wrote:
> You say in the definition of mappings that at present Python has only
> one type of it, the dictionnary. I suggest another one, the sparse
> array, where absence of key would mean not absence of element but
> presence of a default-value element, such as zero for sparse arrays in
> the mathematical sense. This would enable the use of mapping with the
> distributive operators as I just suggested them in a previous e-mail.
It's extremely easy to implement something like this. Here's a start:
class SparseList(dict):
def __init__(self, defaultValue=0):
dict.__init__(self)
self.defaultValue = defaultValue
def __getitem__(self, index):
return self.get(index, self.defaultValue)
> I will be pestering you with my suggestions from time to time. You
> say
> Python is an evolving language, prove it.
"Prove it"? To whom, you? Why?
--
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
__ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/ \ Nothing is true -- all is permissible.
\__/ Hassan i Sabbah
More information about the Python-list
mailing list