Best practices for using super()
Lars Liedtke
lal at solute.de
Wed Jul 5 04:34:45 EDT 2023
Hey,
When you have multiple inheritance and you e.g. want to explicitely call __init__ of one of the classes inherited from, that is not the first in the list of classes to inherit from.
Cheers,
Lars
Lars Liedtke
Senior Software Developer
[Tel.] +49 721 98993-
[Fax] +49 721 98993-
[E-Mail] lal at solute.de<mailto:lal at solute.de>
solute GmbH
Zeppelinstraße 15
76185 Karlsruhe
Germany
[Logo Solute]
Marken der solute GmbH | brands of solute GmbH
[Marken]
[Advertising Partner]
Geschäftsführer | Managing Director: Dr. Thilo Gans, Bernd Vermaaten
Webseite | www.solute.de <http://www.solute.de/>
Sitz | Registered Office: Karlsruhe
Registergericht | Register Court: Amtsgericht Mannheim
Registernummer | Register No.: HRB 110579
USt-ID | VAT ID: DE234663798
Informationen zum Datenschutz | Information about privacy policy
https://www.solute.de/ger/datenschutz/grundsaetze-der-datenverarbeitung.php
Am 04.07.23 um 14:20 schrieb Peter Slížik via Python-list:
As a follow-up to my yesterday's question - are there any recommendations
on the usage of super()?
It's clear that super() can be used to invoke parent's:
- instance methods
- static methods
- constants ("static" attributes in the parent class, e.g. super().NUMBER).
This all works, but are there situations in which calling them explicitly
using a parent class name is preferred?
Best regards,
Peter
More information about the Python-list
mailing list