Python Forum
Inheritance vs Instantiation for Python classes
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Inheritance vs Instantiation for Python classes
#2
(Sep-23-2021, 12:31 PM)mr_byte31 Wrote: I am just wondering why there exists two solutions for the same problem.
well, these are two completely different concepts.

Class is a blue-print. Very rough comparison between the two:

Instantiation is creating multiple items (i.e. instances) based on the same blue print. All instances of the same class have exactly the same attributes.

Inheritance is when one class have some attributes from the parent class (or classes in case of multiple inheritance), but at the same time extend the parent class with new attributes or overload some attributes with different implementation.

e.g. having class Animal and then class Mammal, class Bird and class Reptile, etc. that inherit from it. You will instantiate child class if you need an object that is instance of e.g. class Mammal.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
RE: Inheritance vs Instantiation for Python classes - by buran - Sep-23-2021, 12:46 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python Classes rob101 4 567 Feb-05-2024, 06:51 PM
Last Post: rob101
  Understanding Python classes PythonNewbee 3 1,228 Nov-10-2022, 11:07 PM
Last Post: deanhystad
Sad Python classes PythonNewbee 4 1,087 Nov-09-2022, 01:19 PM
Last Post: deanhystad
  Understanding Python super() for classes OmegaRed94 1 1,860 Jun-09-2021, 09:02 AM
Last Post: buran
  Python classes Python_User 15 4,977 Aug-04-2020, 06:57 PM
Last Post: Python_User
  XlsxWriter and Python inheritance aquerci 1 2,528 May-05-2020, 09:36 AM
Last Post: buran
  Python Classes leodavinci1990 1 2,112 Nov-27-2019, 07:25 AM
Last Post: buran
  How inheritance works in Python ARV 1 1,856 Oct-03-2019, 03:06 PM
Last Post: Larz60+
  Problems with inheritance with classes internetguy 3 2,648 Jul-04-2019, 11:59 AM
Last Post: metulburr
  Unexpected Output using classes and inheritance langley 2 1,977 Jul-04-2019, 09:33 AM
Last Post: langley

Forum Jump:

User Panel Messages

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