Whats the difference between:
class Animal(object):
pass
a = Animal;
a.asdas = 2;
print(vars(a))
output:
{'asdas' : 2}
and
class Animal(object):
pass
a = Animal();
a.asdas = 2;
print(vars(a))
output:
{'asdas': 2, '__doc__': None, '__dict__': <attribute '__dict__' of 'Animal' objects>, '__weakref__': <attribute '__weakref__' of 'Animal' objects>, '__module__': '__main__'}
Why is the output so different, it seems that a=Animal()
does not create the same object as a=Animal
. Isnt this confuse?
From the answers the following got clear:
It's very confuse when you come from the programming world like (C/C++).
I was expecting a = Animal
also calls the constructor with empty arguments...