True = 0
False = -1
<<Could you please explain what is so egregious about those two lines for those people that may not see it? Asking for a friend.
True = 0
False = -1
<<Could you please explain what is so egregious about those two lines for those people that may not see it? Asking for a friend.
This script is changing it to be backwards, and python is flexible enough to allow that. But I would expect this would break most python libraries, because it's such a core language feature that's being completely restructured.
Is there a valid use case for changing the numeric values of True and False?
No! Actually I take it back this _is_ definitely still a terrible idea and will lead to certain madness for all involved. :)
Python 2 has _many_ quirks like this one. Python 3 was not just "it's unicode".
[1] https://docs.python.org/3/whatsnew/3.0.html#changed-syntax
(Python has a search path: it looks first on the current module, then on the built-in __builtins__ module, which is where the built-in constants and functions reside.)
However maybe the professor needed 'true/false' to represent something to be used in his formulas so this made sense to him. But who knows.
>>> True = 0
>>> False = -1
>>> if False: print('oh no')
False is now truthy and True is falsey. Note this only works in python2.