python - Why does __mro__ not show up in dir(MyClass)? -


class myclass(object):     pass  print myclass.__mro__ print dir(myclass) 

output:

(<class '__main__.myclass'>, <type 'object'>) ['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__'] 

why __mro__ not listed dir() ?

from python documentation:

because dir() supplied convenience use @ interactive prompt, tries supply interesting set of names more tries supply rigorously or consistently defined set of names, , detailed behavior may change across releases. example, metaclass attributes not in result list when argument class.

__mro__ read-only attribute that's used determine method resolution in case class inherits multiple base classes. if wish customize behavior, should use metaclass (a special kind of object purpose create class instances) overrides mro() method. __mro__ left unchanged in case.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -