Define abstract class Animal : Class abstract : Class PYTHON examples


PYTHON examples » Class » Class abstract »

 

Define abstract class Animal


Define abstract class Animal


class Animal:
    def reply(self):   
       self.speak()        
    def speak(self):   
       print 'spam'        

class Mammal(Animal):
    def speak(self):   
      print 'speak?'

class Cat(Mammal):
    def speak(self):   
       print 'Speak from Cat'

class Dog(Mammal):
    def speak(self):   
       print 'Speak from Dog'

class Primate(Mammal):
    def speak(self):   
       print 'Speak from primate!'

class Hacker(Primate): pass     

if __name__ == '__main__':
    spot = Cat()
    spot.reply()        
    data = Hacker()     
    data.reply()


           
       



    Related Scripts with Example Source Code in same category :

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo Class
» Class abstract