What’s a good way to implement a type safe dictionary in Python (3.2) – a dictionary that will only allow adding objects of a particular type to itself?
I myself have a simple solution: build a wrapper class around the dictionary with an ‘addItem’ method that does a type check assertion before adding the object. Looking to see if someone has something better.
I think you can extend the dictionary and overwrite the
__setitem__method