python subclass

class SuperHero(object): #superclass, inherits from default object
    def getName(self):
        raise NotImplementedError #you want to override this on the child classes

class SuperMan(SuperHero): #subclass, inherits from SuperHero
    def getName(self):
        return "Clark Kent"

class SuperManII(SuperHero): #another subclass
    def getName(self):
       return "Clark Kent, Jr."

if __name__ == "__main__":
    sm = SuperMan()
    print sm.getName()
    sm2 = SuperManII()
    print sm2.getName()

3.9
10
Scandihuvian 110 points

                                    class SubClass(SuperClass):
  super().__init__(self,atr1,atr2)
  super().SomeMethod(self)
  def OtherMethod(self,atr3):
    pass #Do Things
  def OverwrittenMethod(self,atr1,atr4):
    pass #If you create a method with the same name as on in the superclass
  		 #The one in the subclass will overwite the original methos

3.9 (10 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
python subclass method making subclass in python class and subclass in python class subclass pytho define subclass python sub class in python python class and subclass class and subclasses python python3 subclass subclass in python def who to make a sub class in python how to define a subclass in python python subclassing a method __subclasses__ python python str subclass subclass of object class in python __subclasses__ python what is subclass in python type subclass python define a subclass in python subclassimg method python python sub class how to make a subclass python subclass python 3 make a subclass python python sub subclass python subclass object python subclass sub class python how to create subclass in python python name subclass phython class subclass python class subclass example create subclass python what is a subclass in python subclass of class python python __subclasses__ .__subclasses__() python python sub-class sub classes python python method and subclass how to subclass attribute python are there subclasses in python python class .subclasses what is subclassing in python subclassing classes python class and subclass python how to do subclasses in python create subclass in python subclass in pythin python define subclass python how to make a subclass how to define subcalss in python make subclass python python subclass init python document subclasses what does init subclass do python Define a Superclass/Parent Class (Inheritance) Define 2 minimum subClass/Child class (Child extends Parent) Define Attributes and Behaviors Define how the classes could be reused in visual basic class subclass python class with subclass python python make subclass from a subclass python make subclass of a subclass python subclass of a subclass python class and subclass example python how to subclass python create subclass with diffrent init how to inherit an attribute form a methed in a class python subclassing python subcalsses subclasses() python subclassing python init python substr how to subclass in python python subclass inherit one method how to make a subclass in python subclacsse python how sub classes work python subclass making python subclass of a class python can a subclass inherit from another subclass python how do subclasses work python python classes and subclasses python subclass list hirreritage python why subclass object python python init subclass python class subclass sub classes in python inheritence of attributes in python subclass and classes inp ython subclasses in python python how to make sure a class is subclassed def own init in subclass python can function objects participate in inheritence Inheritance allow subclasses to add or overwrite methods and attributes of their parent classes. python + subclass subclass in python subclass superclass python subclasses python python declare subclass py how to inherit class postfestum extending if else in subclass python inherence python3 how to create a subclass python python subclasses inheriting superclass properties in python syntaxsub class in python inherit self in python creating a subclass in python python inheritance with subclass main classes and its subclasses in oop python how to create a subclass in python how to inherit one function in another python class inheritance python return derived classes vs underclasses python how to inherit the properties of a parent class to subclass python laoding subclass inheretence pythion how to use attribute and method of inheritance class in python how to use subclasses python how to make subclasses in python python subclasses exampe subclassing python python make a subclass python oop how to implement parent and child class python class hierarchy python inherit B from A apply an inherited function python subclassess python python class extend inheritance inherit method from class to subclass in python implement a subclass in python subclass inheritance python how to inherit attribute and methods of one class in python python subclass example python subclassing a class how to create a how to make a child class derived from multiple parents python python subclass creating an object of a subclass python subclassing in python subclass python python subcalss
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source