14 lines
342 B
Python
14 lines
342 B
Python
## Defaultdict magic
|
|
|
|
from collections import defaultdict
|
|
|
|
defaultobj = lambda: type('defaultobj', (defaultdict,), {
|
|
'__getattr__': lambda self, x: self.__getitem__(x),
|
|
'__setattr__': lambda self, x, v: self.__setitem__(x, v)
|
|
})(defaultobj)
|
|
|
|
names = defaultobj()
|
|
names.mammalia.primates.homo['H. Sapiens'] = 'Human being'
|
|
|
|
print(names)
|