When I am trying to check type of class declaration in Python 3 and Python 2, I get strange results, as followings show,
>>> #python 2.7.6
>>> class MyClass:
... pass
...
>>> type(MyClass)
<type 'classobj'>
>>> hasattr(MyClass, '__call__')
False
The type of MyClass in Python 2 is classobj and MyClass has no __call__ attribute. This is what I expect.
>>> #python 3.3.3
>>> class MyClass:
... pass
...
>>> type(MyClass)
<class 'type'>
>>> hasattr(MyClass, '__call__')
True
However, in Python 3, the type of MyClass is class 'type', and MyClass has __call__ attribute although I don't declare it within MyClass.
I guess the reason is that in Python 3, MyClass is a type, and type has __call__ attribute, am I right? and why Python 3 change the behavior of type function like this?