Python Forum
Class Attributes Inheritance
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Class Attributes Inheritance
#3
1. Init product need variables define.
class Inventory(Product):
    def __init__(self, pnbr, products)
        Product.__init__(self, "product name", 1, 20)
2. if you want a list of products do not inherit products
class Inventory:
    def __init__(self, pnbr, products)
        self.pnbr = pnbr
        self.products = products

    def cost(self, product_index):
        return self.products[product_index].pcost * self.pnbr
99 percent of computer problems exists between chair and keyboard.
Reply


Messages In This Thread
Class Attributes Inheritance - by Harry_Potter - Nov-16-2017, 06:50 AM
RE: Class Attributes Inheritance - by Harry_Potter - Nov-16-2017, 03:22 PM
RE: Class Attributes Inheritance - by Windspar - Nov-16-2017, 03:56 PM
RE: Class Attributes Inheritance - by snippsat - Nov-16-2017, 07:01 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  super() and order of running method in class inheritance akbarza 7 1,025 Feb-04-2024, 09:35 AM
Last Post: Gribouillis
Question [solved] Classes, assign an attributes to a class not to instances.. SpongeB0B 4 1,120 May-20-2023, 04:08 PM
Last Post: SpongeB0B
  Child class inheritance issue eakanathan 3 1,508 Apr-21-2022, 12:03 PM
Last Post: deanhystad
  [Solved] Novice question to OOP: can a method of class A access attributes of class B BigMan 1 1,430 Mar-14-2022, 11:21 PM
Last Post: deanhystad
  Distinguishing different types of class attributes Drone4four 4 2,332 Feb-21-2022, 06:34 PM
Last Post: deanhystad
  Importing issues with base class for inheritance riccardoob 5 4,994 May-19-2021, 05:18 PM
Last Post: snippsat
  Calls to Attributes of a Class SKarimi 3 3,598 Apr-22-2021, 04:18 PM
Last Post: SKarimi
  3D vector class with inheritance from 2D vector class buss0140 4 3,353 Dec-20-2020, 08:44 PM
Last Post: deanhystad
  Class inheritance oclmedyb 3 2,400 Dec-09-2020, 04:43 PM
Last Post: deanhystad
  Can we access instance variable of parent class in child class using inheritance akdube 3 14,210 Nov-13-2020, 03:43 AM
Last Post: SalsaBeanDip

Forum Jump:

User Panel Messages

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