Long time ago a thought came, why does a python dict throw exception, can't it just return a None if there is no key with supplied name.
Well now I understand the point of it, which is very obvious - if a dict has a key "foo" and the programmer has stored None into it, how would one distinguish a non-existant key and the one with None stored into it.
So here is the desired bad extension of dict for the Community Centric Python(CCP) Engineer:
l = NoneDict()
l = "Foo"
l["a"] = "Bar"
print l, l["a"] # gives out the values
print l # gives out None
Labels: ccp, fail, python