[Python-Dev] Proposal: defaultdict (original) (raw)
Raymond Hettinger python at rcn.com
Sun Feb 19 04:53:35 CET 2006
- Previous message: [Python-Dev] Proposal: defaultdict
- Next message: [Python-Dev] Proposal: defaultdict
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> Also, I think haskey/in should return True if there is a default.
It certainly seems desirable to see True where d[somekey] doesn't raise an exception, but one could argue either way.
Some things can be agreed by everyone:
if contains always returns True, then it is a useless feature (since scripts containing a line such as "if k in dd" can always eliminate that line without affecting the algorithm).
if defaultdicts are supposed to be drop-in dict substitutes, then having contains always return True will violate basic dict invariants: del d[some_key] assert some_key not in d
Raymond
- Previous message: [Python-Dev] Proposal: defaultdict
- Next message: [Python-Dev] Proposal: defaultdict
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]