Lets say I have the code:
class NoneDict(dict):
def __getitem__(self, name):
try:
return super(NoneDict, self).__getitem__(name)
except:
return None
I want people to be able to create a NoneDict object without writing all this code out. I tried including it in a module and then typed:
import nonedict
foo = NoneDict()
But it didn’t work. How can I make it so someone can import the module and then be able to create a nonedict without typing out all the code?
or
or (thanks @Joel Cornett)