Re:Implementing Function Overloading in Python
by mrkeen on Thursday March 26, 2020 @10:39AM
(#22693976)
If you allow both
and
to exist, then in the future you won't be able ask what the type of 'area' is. (If that's your kind of thing)
[ Parent
| on HN ]
Re:Implementing Function Overloading in Python
by zomglings on Thursday March 26, 2020 @12:24PM
(#22695189)
You will, the type could be Union[int, float].
Alternatively, you could also use the abstract base classes in the numbers module - https://docs.python.org/3/library/numbers.html
numbers.Number may be a good choice.
Still, you are right, overloading like this may be okay as a thought exercise, but would raise some serious questions during a code review. :)