Re: Multiple inheritance and a broken super() chain

2023-07-05 Thread Alan Gauld via Python-list
On 05/07/2023 01:27, Chris Angelico via Python-list wrote:

>> So I'm curious about how big this "big problem with MI" is in
> 
> Who said it's a big problem with MI? 

I think it's a very common perception, particularly with
newer programmers who have never used it in anger. Any
time anyone discusses MI it seems somebody will jump in
and warn about diamonds etc. As a result many steer clear
of MI, which is a shame.

My personal experience of MI is that used appropriately
it is a powerful and useful tool. But it must be used
in a true is-a type relationship and not just as a kind
of cheap reuse mechanism - that's when problems start.

Also, mixin style MI is particularly powerful but the
protocol between mixin and "subclass" needs to be carefully
designed and documented. Like any powerful tool you need
to understand the costs of use as well as the potential
benefits.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Best practices for using super()

2023-07-05 Thread Lars Liedtke via Python-list

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]l...@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 
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

--
https://mail.python.org/mailman/listinfo/python-list