What is the relation between the dog and animal classes in this Python code? -


class animal(object):             pass  class dog(animal):         def __init__(self):             print "i got called" 

i found code in book "learn python hard way". have questions relationship between dog , animal?

are dog , animal both classes , dog inherit animal?

the class dog inherited class animal. means object of class dog gets attributes , methods animal class defines. class dog called subclass or inherited class while class animal called superclass or parent class.

usually subclass used extend functionality of class. class dog can modify attributes and/or functionalities of animal and/or add own.


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

python 3.x - PyQt5 - Signal : pyqtSignal no method connect -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)