This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: list type and UserList do not call super in __init__ and therefore, they cannot be parents in a multiple inheritence scheme
Type: behavior Stage: resolved
Components: Extension Modules Versions: Python 3.10, Python 3.9
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Sagiv.Malihi, alonho, benjamin.peterson, daniel.urban, rhettinger
Priority: normal Keywords:

Created on 2010-05-16 16:48 by alonho, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg106047 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2010-05-19 11:47
Why does it matter? They both inherit from object, so there's no one to pass parameters to.
msg106070 - (view) Author: Sagiv Malihi (Sagiv.Malihi) Date: 2010-05-19 13:40

class A(object):
 def __init__(self):
  print "initializing something very important"
  # and then pay it forward...
  super(A, self).__init__()

class B(list, A): pass

b = B()
# A's init is never called...
msg381576 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2020-11-21 21:41
There will always be classes that don't call super() init, sometimes for efficiency and sometimes to preserve their internal invariants.

Also, __init__() isn't the only method affected.  For a perfectly cooperative class, all of the methods would need to call super().

See how to handle this in the "How to Incorporate a Non-cooperative Class" section of:
Date User Action Args
2022-04-11 14:57:01adminsetgithub: 52979
2020-11-21 21:41:15rhettingersetstatus: open -> closed

nosy: + rhettinger
messages: + msg381576

resolution: not a bug
stage: resolved
2020-11-21 18:21:16iritkatrielsetversions: + Python 3.9, Python 3.10, - Python 3.5
2014-01-31 21:49:03yselivanovsetversions: + Python 3.5, - Python 3.3
2010-07-25 17:22:42daniel.urbansetnosy: + daniel.urban
2010-05-19 13:40:29Sagiv.Malihisetmessages: + msg106070
2010-05-19 11:47:22benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg106047
2010-05-17 08:58:29Sagiv.Malihisetnosy: + Sagiv.Malihi
2010-05-16 16:48:56alonhocreate