4 ms·
Oh, I was somehow hoping this would allow you to have multiple function signatures. i.e. two functions foo, both accepting one variable named bar, but one would
by rplnt 11y ago
Oh, I was somehow hoping this would allow you to have multiple function signatures. i.e. two functions foo, both accepting one variable named bar, but one would implement str and one int, for example.
- zsiciarz 11y agoYou can have that since 3.4, thanks to PEP 443 (https://www.python.org/dev/peps/pep-0443/ https://www.python.org/dev/peps/pep-0443/). Here's a (slightly contrived) example: https://gist.github.com/zsiciarz/e15199d9be1b0e07faf6 https://gist.github.com/zsiciarz/e15199d9be1b0e07faf6
- rootlocus 11y agoTo help with the phrasing: this is called function overloading. Type hinting is ignored by the interpreter so it doesn't add any new functionality, only documentation.