Change name of imported type (aliasing)
The goal is to make code more productive and clean in cases where multiple classes with same name must be used in code. It should relief a developers frustration in that
class Vividict(dict): | |
""" | |
dict class which allows to set deeply nested values. Any nested dict will get autovivified. | |
Note that using defaultdict is more performant, so in case of huge datasets revert to that one. | |
However using this class and not 'closing' it after setting values might result in undesired behavior: | |
When accessing a value which is not set, no KeyError is thrown, instead it's autovivified into an empty Vividict. | |
To guarantee this doesn't happen but KeyError is thrown, dictify() needs to be called to transform the data structure | |
into regular dicts. | |
--- | |
bubbles: | |
- xpos: 20 | |
ypos: 50 | |
diameter: 200 | |
emotion: happy | |
- xpos: 80 | |
ypos: 60 | |
diameter: 210 | |
emotion: sad |
.:' | |
..:' | |
.;' | |
.;!; | |
.;;;;,;;,;;,,,. | |
.,;;;'''''';;..,;;;,; | |
`'',CC;;;;;;'.....;;;. | |
:.............,'`...;;;;;;;.............;;\. :::::::::: | |
;;;;;;..,,,...,,..........;' :::::::::::;;;;;;;;;'.. | |
:::::::::::' :: `'':::::......,,,;::::::::::::::::' |