I am working on Mac OS X Yosemite with python 2.7.9.
Here is what I tried:
define class
class A:
def test(self):
print "test"
then run
A.__mro__
then i got
>>> A.__mro__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: class A has no attribute '__mro__'
Then i define
class B(object):
def test(self):
print "test"
then run
B.__mro__
then i got
>>> B.__mro__
(<class '__main__.B'>, <type 'object'>)
What is the difference between these two definitions? I found that in python 3 in the edition without an object there is a method __mro__.
source
share