rapydscript-ng: False == 0 fails
Recipe: Consider the following seemingly-innocent program:
a = 3==4
print("yyyyy", a, 0, a==0)
Desired and expected output:
yyyyy False 0 True
This works as expected under real python from the command line. The corresponding javascript also works as expected. However…
Observed rapydscript behavior:
yyyyy false 0 false
This is 100% reproducible chez moi. I am using the latest rapydscript-ng, from a fresh git-pull. FWIW the old non-ng version exhibits the same misbehavior.
This is more important than it might seem. The example above is highly simplified, to facilitate debugging. The same issue affects more-complicated code in ways that are much harder to understand. This wastes significant amounts of programmer time.
This started out as BruceSherwood/glowscript#60 but is hereby pushed upstream.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 18 (10 by maintainers)
I’m going to spell it out one last time for anyone else reading this bug report.
There is only one possible reason to do
a == 0when a is of unknown type, and that is to check its truthiness. You trying to move the goalposts notwithstanding.Using
a == 0to check truthiness is wrong, because it fails when a is any of; None, empty list, empty tuple, empty set, empty dict, empty string, any user defined type with a__bool__method.Your proposed solution, to use the javascript
==operator instead of the===operator is so stupid, it boggles the mind. You want to bring in all the infelicities of the JS == operator in order to enablea == 0, which is a stupid thing to do in the first place. And here is a link that explicates some of the problems with the==operator in JS. http://stackoverflow.com/questions/359494/does-it-matter-which-equals-operator-vs-i-use-in-javascript-comparisons@JohnDenker Dont bother replying (although I suspect you cannot resist) I have blocked you.