EDIT: a solution is in this answer: How to use a dot “.” to access members of dictionary?
When using a dict:
d = dict()
d['param1'] = 17
d['param2'] = 3
it's easy to print it with print json.dumps(d)
. When using an object / class:
class z:
pass
z.param1 = 17
z.param2 = 3
I can't manage to print all the attributes of z, neither with print json.dumps(z)
, nor with print z
. How to do it?
Sidenote but important: why do I want to use a class / object to store parameters, when it would be logical to use a dict? Because z.param1
is much shorter and handy to write than z['param1']
, especially with my (french) keyword [
, ]
, '
are quit long to write because ALT+GR+5 (let's say 2 seconds instead of 0.5, but this really matters when you have a long code with many variables)