Re:Python's “Disappointing” Superpowers
by ReflectedImage on Thursday February 02, 2023 @03:59AM
(#34623996)
That not a bug that static typing would catch as it is not a type bug.
[ Parent
| on HN ]
Re:Python's “Disappointing” Superpowers
by lostmsu on Thursday February 02, 2023 @11:37AM
(#34629001)
What do you mean it is not a type bug? You've seen the fix with your own eyes. In the static language that fix would never have been needed, because the consumer would never have made the mistake that caused the miscalculation in the first place. Of course it is a type bug!
This is along the lines of
def is_valid_email(email): return str(email).contains('@')
class Person:
...
def __str__(self): return $"{self.name} <{self.email}>"
print(is_valid_email(Person(name='Peter @ Work', email=None)))
Re:Python's “Disappointing” Superpowers
by ReflectedImage on Thursday February 02, 2023 @01:40PM
(#34631155)
You can't get a NaN from a None value in Python.
(Duck typing still has rules)
The error you have posted isn't a Python error.
Looking a bit deeper, the error occurs in C++ code. C++ is a statically typed language, last time I checked.