I would like to know if the two approaches are equivalent:
Approach 1
class A:
toto = 1
vs, Approach 2:
class A:
def __new__(cls, *args, **kwargs):
cls.toto = 1
return super().__new__(cls, *args, **kwargs)
To me they look the same. Especially, printing dir(A) gives the same result:
['__class__',
'__delattr__',
'__dict__',
'__dir__',
'__doc__',
...
'toto']
Thanks