Polymorphism in Python
Polymorphism in Python
What is Polymorphism?
In some cases Methods in the child class have the same name as
the methods in the parent class.
This is mostly used in cases where the method inherited from the
parent class doesn’t suite the child class….
The print statement and str() built-in function uses __str__ to display the
string representation of the object passed to it
import datetime
today = datetime.datetime.now()
# Prints readable format for date-time object
print str(today)
{ Internally the str function calls today.__str__}
2016-02-22 19:32:04.078030