I am finding it difficult to implement polymorphism in Python... 
Archived topic from Iceteks,  old topic ID:4520, old post ID:36072
			
			
									
						
										
						Objects in Python
Objects in Python
 How so?
			
			
									
						
										
						Code: Select all
class Dog(object):
   def bark(self):
      return "Ruff!"
class Tree(object):
   def bark(self):
      return "Rough!"
def speak(obj):
   print obj.bark()
fido = Dog()
leafy = Tree()
say(fido)
say(leafy)[code] 
[color=#888888][size=85]Archived topic from Iceteks,  old topic ID:4520, old post ID:36099[/size][/color]