TLDR: Python's Missing Feature - Function Overloading
Date: 2020-02-07 Source: https://arpitbhayani.me/blogs/function-overloading
Overview
Explore function overloading in Python! Learn how to implement it using decorators and namespaces, despite Python's limitations. When we define multiple functions with the same name, the later one always overrides the prior and thus, in the namespace, there will always be a single entry against each function name.
Key Points
- Why no Function Overloading in Python?: Python does not support function overloading.
- Wrapping the function: We create a class called Function that wraps any function and makes it callable through an overridden call method and also exposes a method called key that returns a tuple which makes this function unique in entire codebase.
- Building the virtual Namespace: Virtual Namespace, we build here, will store all the functions we gather during the definition phase.