Quote:
Originally Posted by topheraholic
what is the difference between
Code:
object.__class__ and object().__class__
thanks very much!
|
object is a class.
object() is an instance of the class 'object'.
object.__class__ is referring to the class of the object class.
object().__class__ is referring to the class of an instance of the 'object' class.
So,
object().__class__.__class__ is the same as
object.__class__
Quote:
Originally Posted by topheraholic
i got an error when i ran
who can tell me why?
|
two is a class. So you might expect
two.__class__ to be:
<type 'classobj'>.
But then
two.__class__.__class__ would be:
<type 'classobj'> too.
And
two.__class__.__class__.__class__.__class__.__class__ too. This never ends. That is why, I suppose, <class>.__class__ is not defined.