Skip to content

Instantly share code, notes, and snippets.

View g-io's full-sized avatar

Ole Göbbels g-io

  • Volkswagen SID Berlin
  • Berlin
View GitHub Profile
@g-io
g-io / .List and use boto3 exceptions
Last active March 9, 2020 08:23
Boto3 Exceptions List
List and use boto3 exceptions
@g-io
g-io / Vividict.py
Last active May 10, 2018 12:31
Python autovivified nested dictionary
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.