2 ms·
If you allow both int area(int length, int breadth) and float area(int radius) to exist, then in the future you won't be able ask what the type of 'area
by mrkeen 7y ago
If you allow both
int area(int length, int breadth)
and
float area(int radius)
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)
- zomglings 7y agoYou 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 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. :)