Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 542609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:27:53+00:00 2026-05-13T10:27:53+00:00

What does mro() do? Example from django.utils.functional : for t in type(res).mro(): # <—–

  • 0

What does mro() do?


Example from django.utils.functional:

for t in type(res).mro():  # <----- this
    if t in self.__dispatch:
        return self.__dispatch[t][funcname](res, *args, **kw)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T10:27:53+00:00Added an answer on May 13, 2026 at 10:27 am

    Follow along…:

    >>> class A(object): pass
    ... 
    >>> A.__mro__
    (<class '__main__.A'>, <type 'object'>)
    >>> class B(A): pass
    ... 
    >>> B.__mro__
    (<class '__main__.B'>, <class '__main__.A'>, <type 'object'>)
    >>> class C(A): pass
    ... 
    >>> C.__mro__
    (<class '__main__.C'>, <class '__main__.A'>, <type 'object'>)
    >>> 
    

    As long as we have single inheritance, __mro__ is just the tuple of: the class, its base, its base’s base, and so on up to object (only works for new-style classes of course).

    Now, with multiple inheritance…:

    >>> class D(B, C): pass
    ... 
    >>> D.__mro__
    (<class '__main__.D'>, <class '__main__.B'>, <class '__main__.C'>, <class '__main__.A'>, <type 'object'>)
    

    …you also get the assurance that, in __mro__, no class is duplicated, and no class comes after its ancestors, save that classes that first enter at the same level of multiple inheritance (like B and C in this example) are in the __mro__ left to right.

    Every attribute you get on a class’s instance, not just methods, is conceptually looked up along the __mro__, so, if more than one class among the ancestors defines that name, this tells you where the attribute will be found — in the first class in the __mro__ that defines that name.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How does super() work with multiple inheritance? For example, given: class First(object): def __init__(self):
Does anyone know how to make this code stop the knob from rotating past
Does this leak?: static PyObject* foo(PyObject* self, PyObject* args){ PyObject* list = PyList_New(0); for(int
Does anyone know why UsernameExists wont return True. I must have my syntax messed
Does anybody know why this function, when passed an invalid date (e.g. timestamp) to
Does this line of Perl really do anything? $variable =~ s/^(\d+)\b/$1/sg; The only thing
Does anyone know why this bean is getting instantiated multiple times? I only ever
Does anyone know how I can directly access a function from a PHP class
Does anyone have a working, step-by-step example of how to implement IEnumerable and IEnumerator
Does anyone know how to add a generic principal to the HTTPContext from the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.