Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

duck typing in python

class Duck(object): 
   def quack(self): 
      print "Quack" 
 
class Mallard(object): 
    def quack(self): 
        print "Quack Quack" 
 
def shoot(bird): 
    bird.quack() 
 
for target in [Duck(), Mallard()]: 
   shoot(target)
Source by www.quora.com #
 
PREVIOUS NEXT
Tagged: #duck #typing #python
ADD COMMENT
Topic
Name
3+2 =