You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would have expected this code to fail with a NotImplementedError because the bool case wasn't specified; but instead, that case is handled by the int implementation because
In [3]: issubclass(bool, int)
Out[3]: True
Decision. In an int implementation, recognize if the provided value is actually a bool and refuse to process that value.
Consequences. I have been writing in Python for quite a few years now and I might even have encountered this relationship between int and bool types before, but that is not quite a type of thing that I keep in my short-term memory to be able to instantly recognize.
I believe this change can help avert bugs which might be hard to trace otherwise.
The text was updated successfully, but these errors were encountered:
Context. Consider the following piece of code.
(this should be runnable as-is on
classes 0.4.0
.)I would have expected this code to fail with a
NotImplementedError
because thebool
case wasn't specified; but instead, that case is handled by theint
implementation becauseDecision. In an
int
implementation, recognize if the provided value is actually abool
and refuse to process that value.Consequences. I have been writing in Python for quite a few years now and I might even have encountered this relationship between
int
andbool
types before, but that is not quite a type of thing that I keep in my short-term memory to be able to instantly recognize.I believe this change can help avert bugs which might be hard to trace otherwise.
The text was updated successfully, but these errors were encountered: