Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to use the super

class Animal(object):
  def __init__(self, animal_type):
    print('Animal Type:', animal_type)
    
class Mammal(Animal):
  def __init__(self):

    # call superclass
    super().__init__('Mammal')
    print('Mammals give birth directly')
    
dog = Mammal()

# Output: Animal Type: Mammal
#         Mammals give birth directly
Comment

how to use the super

class Animal(object):
  def __init__(self, animal_type):
    print('Animal Type:', animal_type)
    
class Mammal(Animal):
  def __init__(self):

    # call superclass
    super().__init__('Mammal')
    print('Mammals give birth directly')
    
dog = Mammal()

# Output: Animal Type: Mammal
#         Mammals give birth directly
Comment

how to use the super

class Animal(object):
  def __init__(self, animal_type):
    print('Animal Type:', animal_type)
    
class Mammal(Animal):
  def __init__(self):

    # call superclass
    super().__init__('Mammal')
    #or you can use
    super().__init__()
    print('Mammals give birth directly')
    
dog = Mammal()

# Output: Animal Type: Mammal
#         Mammals give birth directly
Comment

PREVIOUS NEXT
Code Example
Python :: binary to string python 
Python :: check if list is empty python 
Python :: isinstance function python 
Python :: python array looping 
Python :: how to swap two variables without using third variable python 
Python :: get a column of a csv python 
Python :: envScriptsactivate.ps1 : File 
Python :: create numpy array with ones 
Python :: python join list 
Python :: qpushbutton pyqt5 
Python :: python variable is not none 
Python :: Bar Charts bokeh 
Python :: set value through serializer django 
Python :: int to char python 
Python :: python png library 
Python :: selenium undetected chromedriver error 
Python :: iterate through directories in python 
Python :: anagram python 
Python :: python function with two parameters 
Python :: associate keys as list to values in python 
Python :: print string elements in list python 
Python :: get median using python 
Python :: create a 2d array in python 
Python :: enable time layer arcpy 
Python :: transpose matrix in python without numpy 
Python :: which function to use in random module for a list in python 
Python :: arrayfield django example 
Python :: pytorch mse mae 
Python :: resize cmd using python 
Python :: how to access the last element of a list in python 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =