First page Back Continue Last page Overview Graphics

Polymorphism

Polymorphism is often defined as the overloading of functions based on the type signatures of their arguments.

This is different in Python as there is no type declaration in Python.

Polymorphism in Python is grounded on object interfaces instead of types.

You could try to implement something like this:

class NN:

def abc(self,x):

pass

def abc(self,x,y):

pass

This code will run, but not in the intended way.

It's like having two assignments to the same name in sequence:

a = 5

a = 7

The second definition will be the one overwriting the first one.