Considering memory use, clock cycles or good pythonic style is it better to do this:
def func():
class A:
x = 10
y = 20
return A
or this
def func():
o = object()
o.x = 10
o.y = 20
return o
Or something else? I don’t want to return a dictionary because I don’t like having to use the square brackets.
I like to use a special way of crafting a
dictsubclass which I found here. It looks like:This object can be used this way:
The different types of access can be used in a exchangeable way.