magical expanding hash
deliverable at gmail.com
Tue Jan 17 23:54:53 CET 2006
Can assigning to hash without intermediate levels, possibly adding to a
numeric leaf or adding an element to a leaf array, be python code?
h['a']['b']['c'] += 42
If it can, I'd like to have a class which supports it.
Is keeping a list at the leaf of a hash python code?
h['a']['b']['c'].push(7) # or override push as an operator of your
Hashes with accumulating lists or counters at the leaves are universal
data structures used in python as much as anywhere else. Python is
used for scripting purposes at least as much as for some abstract ones.
Having a useful data structure is handy.
The multi-level hashes with default or accumulation come up naturally
in text parsing. Designing a dedicated class structure may or may not
be a better choice, depending on expediency.
More information about the Python-list