Python Dunder Methods and Polymorphism

Subscribers:
50,600
Published on ● Video Link: https://www.youtube.com/watch?v=igtpgiyIkvY



Duration: 14:21
195 views
0


Python dunder functions and operator overloading by implementing the Complex Number class.
Polymorphism means "different forms". So far we have created methods and dunder methods (operator overloading) as 2 ways of doing the same thing. For instance, we can create an add( ) method, or overload the __add__ operator.

We can apply the concept of polymorphism in our Complex Number class for function parameters. Here, we can add other Complex Number types or simple integers to our Complex Number. Unlike other programming languages, Python does not allow us to overload methods (define multiple functions with the same name). Instead since Python is dynamically typed, we can simply check the type of the value passed in to replicate this concept.

Python Playlist:
https://youtube.com/playlist?list=PLnKe36F30Y4bcRomKi02sP9NR27KnBqCK

Github: https://github.com/ImKennyYip/python-data-structures-algorithms

Subscribe for more coding tutorials 😄!







Tags:
python classes
python functions
dunder method python
python dunder methods
python dunder method
python operator overloading
python dunder functions
dunder functions python
dunder functions in python
dunder method in python
dunder methods in python
operator overloading python
python operator overload
operator overloading in python
python dunder operator
dunder operator in python
dunder operators in python
python dunder