Compare:
###
class Dog(object): pass
class Cat(object): pass
class Cow(object): pass
def sayHi(animal):
if isinstance(animal, Dog):
print("Woof")
elif isinstance(animal, Cat):
print("Meow")
elif isinstance(animal, Cow):
I meant to add...
On 04/01/14 20:47, Alan Gauld wrote:
Its called polymorphism and is one of the most powerful advantages of
OOP since case or switch statements are one of the most fault prone
structures in procedural programming.
...
Without OOP you would need to do something like
for shape i
On 04/01/14 20:11, Alex Kleider wrote:
Assuming I am correct that in Python, switch statements must be
implemented as a series of if; elif; .. statements, how is it that this
can be avoided by creating subclasses?
Its called polymorphism and is one of the most powerful advantages of
OOP sinc