[Python-Dev] defaultdict proposal round three (original) (raw)
Greg Ewing greg.ewing at canterbury.ac.nz
Tue Feb 21 10:59:06 CET 2006
- Previous message: [Python-Dev] defaultdict proposal round three
- Next message: [Python-Dev] defaultdict proposal round three
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Bengt Richter wrote:
you could write
d = dict()**list
Or alternatively,
ld = dict[list]
i.e. "a dict of lists". In the maximally twisted form of this idea, the result wouldn't be a dict but a new type of dict, which you would then instantiate:
d = ld(your_favourite_args_here)
This solves both the constructor-argument problem (the new type can have the same constructor signature as a regular dict with no conflict) and the perceived-Liskov-nonsubstitutability problem (there's no requirement that the new type have any particular conceptual and/or actual inheritance relationship to any other type). Plus being a really cool introduction to the concepts of metaclasses, higher-order functions and all that neat head-exploding stuff. :-)
Resolving-not-to-coin-any-more-multihyphenated- hyperpolysyllabic-words-like-'perceived-Liskov- nonsubstitutability'-this-week-ly,
Greg
- Previous message: [Python-Dev] defaultdict proposal round three
- Next message: [Python-Dev] defaultdict proposal round three
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]