Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Python's static type system can express what you describe using TypeVars or overloads. The issue is that `int pow(int, int)` is fundamentally incorrect. If the exponent is a negative integer, the return type would need to be float.

As evidenced by your comment, most people forget about negative exponents. The vast majority of usage is positive exponents; people expect an int back when they do `pow(2, 2)` and returning a Union or float would result in annoying false positives.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: