jwcnmr / jameswcooper

Example Python code
41 stars 29 forks source link

polymorphism #1

Open zsnmbkmnc opened 2 years ago

zsnmbkmnc commented 2 years ago

https://github.com/jwcnmr/jameswcooper/tree/main/Pythonpatterns/1.%20Intorduction%20to%20Objects/addnumstype.py

This file defines addNums method twice, but adding simple prints in bodies of those definitions (e.g. print("func one") and print("func two")) shows that the only method invoked is the second one (last one defined, technically). Alternatively, you could try to change the order of definitions - this would raise the error during execution.

Such polymorphism doesn't exist in Python.

Cheers!

jwcnmr commented 2 years ago

Thanks for reading my work and for your suggestions

Sent from my iPhone

On Jan 17, 2022, at 8:11 PM, zsnmbkmnc @.***> wrote:

 https://github.com/jwcnmr/jameswcooper/tree/main/Pythonpatterns/1.%20Intorduction%20to%20Objects/addnumstype.py

This file defines addNums method twice, but adding simple prints in bodies of those definitions (e.g. print("func one") and print("func two")) shows that the only method invoked is the second one (last one defined, technically). Alternatively, you could try to change the order of definitions - this would raise the error during execution.

Such polymorphism doesn't exist in Python.

Cheers!

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you are subscribed to this thread.