For a work project we needed a convenient way to wrap our SQL recordset, instance objects and dictionary variables to share the same interface. The result is SmartDict
which makes it possible to assert that access can be made in any which way you want; something that is very useful when you write templates and don't want to have to know if what you're working with is a dict
or a recordset.
This doesn't work:
>>> d= {'name':"Peter"}
>>> print d.get('name') # fine
>>> print d.name # Error!!!
Likewise with some instance objects or record sets, this doesn't work:
>>> d = getRecordsetObject()
>>> print d.name # fine
>>> print d.get('name') # Error!!!