Python Forum
Multiple inheritance - the right way ?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multiple inheritance - the right way ?
#7
@ichabod801

Yes, good point. If two classes have a parent in common, you cannot use the list "__base__".

I was thinking that I could include within the parent class a flag that indicates whether class has been initialised or not : thus the parent class will be initialised only once. However, I think that this would be a bad practice. Indeed, this technique is tightly bound to a specific Python implementation. If Python changes the way it treats multiple inheritance in the future, then this technique will produce errors.

(Feb-13-2019, 05:51 PM)ichabod801 Wrote: snippsat

Yes. I've seen.

However, the function "super" have multiple signatures.

Quote: super() -> same as super(__class__, <first argument>)
super(type) -> unbound super object
super(type, obj) -> bound super object; requires isinstance(obj, type)
super(type, type2) -> bound super object; requires issubclass(type2, type)

It seems that we can call "super()" on the class other than the current one (that is "__class__").

For example, we can call super on a parent class, from a child class. But I cannot see any good reason to do that.
Reply


Messages In This Thread
RE: Multiple inheritance - the right way ? - by denis_beurive - Feb-14-2019, 09:24 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Multiple Inheritance - Help pls! magnusbrigido 1 1,880 May-17-2019, 12:56 PM
Last Post: ichabod801
  Multiple Inheritance using super() Sagar 2 7,368 Sep-08-2017, 08:58 AM
Last Post: Sagar

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020