Skip to content

Instantly share code, notes, and snippets.

@SebDeclercq
Created June 6, 2018 11:17
Show Gist options
  • Select an option

  • Save SebDeclercq/21191ee30bda7678308dc23b8a9be456 to your computer and use it in GitHub Desktop.

Select an option

Save SebDeclercq/21191ee30bda7678308dc23b8a9be456 to your computer and use it in GitHub Desktop.
Essai pour voir si c'est faisable pour CHBO
#!/usr/bin/env python3
class Struct(): pass
def toObject(dictionnaire):
object = Struct()
for nom, element in dictionnaire.items():
if isinstance(element, dict):
setattr(object, nom, toObject(element))
else:
setattr(object, nom, element)
return object
d = {'az': {'er': 123, 'ty': 456}, 'ui': 789, 'op': {'qs': 12}}
s = toObject(d)
print(s.az.ty)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment