Using super()

Michele Simionato michele.simionato at gmail.com
Thu Jul 20 00:09:30 EDT 2006


Carl Banks ha scritto:

> Pupeno wrote:
> > I see, thank you.
> >
> > class MyConfig(ConfigParser, object):
> >     def add_section(self, section)
> >          super(MyConfig, self).add_section(section)
> >
> > seems to work and as expected. Is there anything wrong with it ?
>
> Wow.
>
> I highly recommend not doing this, unless the new type system was
> designed to allow this sort of mixing, which I highly doubt.  There are
> some significant under-the-cover differences between old- and new-style
> classes that could mess everything up when trying to mix them.
>

I believe the new style system was designed to allows this sort of
mixing and
that there are no issues at all. A child of new style + old style is
simply a new
style class. If you do

class NewStyle(OldStyle, object):
   pass

you will see that

type(NewStyle) == type

There should be something more on
http://www.python.org/download/releases/2.2.3/descrintro

(I have seen somewhere how type.__new__ works, and how the metaclass
is chosen, so I am pretty sure sure there are no issue, at least for
pure Python
classes).

                       Michele Simionato




More information about the Python-list mailing list