Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python inheritance

class Base():
    """ My base class """

    __nb_instances = 0

    def __init__(self):
        Base.__nb_instances += 1
        self.id = Base.__nb_instances

class User(Base):
    """ My User class """

    def __init__(self):
        super().__init__()
        self.id += 99

u = User()
print(u.id)
Source by alx-intranet.hbtn.io #
 
PREVIOUS NEXT
Tagged: #python #inheritance
ADD COMMENT
Topic
Name
8+5 =