Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #21493

Re: newb __init__ inheritance

From Peter Otten <__peter__@web.de>
Subject Re: newb __init__ inheritance
Date 2012-03-11 13:12 +0100
Organization None
References (3 earlier) <2feb13ca-f83b-4843-995f-ee77e7505ecd@db5g2000vbb.googlegroups.com> <mailman.560.1331462311.3037.python-list@python.org> <18769501.3541.1331463388634.JavaMail.geo-discussion-forums@ynkz21> <CALwzidnxW5g9kSq+RBtOX5u_EHcevGbX3wqZJcHDc5KFSUwOCA@mail.gmail.com> <CALwzidmYk3sYyoupf=esOXc4OezVsbWh3AB8S-FTp_yNyqFRjg@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.565.1331467945.3037.python-list@python.org> (permalink)

Show all headers | View raw


Ian Kelly wrote:

> On Sun, Mar 11, 2012 at 5:40 AM, Ian Kelly <ian.g.kelly@gmail.com> wrote:
>>> 2. Is the mro function available only on python3?
>>
>> No, but it is available only on new-style classes.  If you try it on a
>> classic class, you'll get an AttributeError.
> 
> And by the way, you probably shouldn't call the mro method directly.
> That method is provided so that it can be overridden in order to
> customize the MRO at class creation.  The proper (and faster) way to
> look up the MRO for a class is using the __mro__ attribute, which
> stores the result of the mro method when the class is initialized.
> 
> http://docs.python.org/library/stdtypes.html?highlight=mro#class.__mro__

Is it a good idea to use mro() or __mro__ at all? Are there common use cases 
that cannot be addressed with super()?

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

newb __init__ inheritance hyperboogie <hyperboogie@gmail.com> - 2012-03-08 07:25 -0800
  Re: newb __init__ inheritance Maarten <maarten.sneep@knmi.nl> - 2012-03-08 08:30 -0800
    Re: newb __init__ inheritance Peter Otten <__peter__@web.de> - 2012-03-08 18:03 +0100
  Re: newb __init__ inheritance Ethan Furman <ethan@stoneleaf.us> - 2012-03-08 09:34 -0800
  Re: newb __init__ inheritance "Colin J. Williams" <cjw@ncf.ca> - 2012-03-10 12:58 -0500
    Re: newb __init__ inheritance "Colin J. Williams" <cjw@ncf.ca> - 2012-03-10 17:47 -0500
      Re: newb __init__ inheritance hyperboogie <hyperboogie@gmail.com> - 2012-03-11 03:18 -0700
        Re: newb __init__ inheritance Chris Rebert <clp2@rebertia.com> - 2012-03-11 03:38 -0700
          Re: newb __init__ inheritance hyperboogie <hyperboogie@gmail.com> - 2012-03-11 03:56 -0700
            Re: newb __init__ inheritance Chris Rebert <clp2@rebertia.com> - 2012-03-11 04:37 -0700
            Re: newb __init__ inheritance Ian Kelly <ian.g.kelly@gmail.com> - 2012-03-11 05:40 -0600
            Re: newb __init__ inheritance Ian Kelly <ian.g.kelly@gmail.com> - 2012-03-11 05:52 -0600
            Re: newb __init__ inheritance Peter Otten <__peter__@web.de> - 2012-03-11 13:12 +0100
          Re: newb __init__ inheritance hyperboogie <hyperboogie@gmail.com> - 2012-03-11 03:56 -0700
  Re: newb __init__ inheritance hyperboogie <hyperboogie@gmail.com> - 2012-03-12 02:09 -0700

csiph-web