• Best practices for using super()

    From =?UTF-8?B?UGV0ZXIgU2zDrcW+aWs=?=@21:1/5 to All on Tue Jul 4 14:20:08 2023
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lars Liedtke@21:1/5 to All on Wed Jul 5 10:34:45 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] [email protected]<mailto:[email protected]>


    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)