4 ms·
In most programming languages, including python, true is represented by 1 and false is represented by 0. This script is changing it to be backwards, and python
by Buge 8y ago
In most programming languages, including python, true is represented by 1 and false is represented by 0.
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.
https://en.wikipedia.org/wiki/Boolean_data_type https://en.wikipedia.org/wiki/Boolean_data_type
- deleted 8y ago[deleted]
- poxrud 8y agoWhen doing comparison checking, in most programming languages false is 0 and true is any other value.
- sorokod 8y agopython is flexible enough to allow that Is there a valid use case for changing the numeric values of True and False?
- tzahola 8y agoNo.
- Lio 8y agoIt’s, IMHO, a terrible idea but the one use I could imagine is if you are doing a lot of stuff with Unix exit codes, where exit code 0 is success. That would cover setting True = 0 ...maybe but not failure which is usually a positive exit code. No! Actually I take it back this _is_ definitely still a terrible idea and will lead to certain madness for all involved. :)
- sametmax 8y agoNo, it's legacy behavior and the community took the opportunity to fix it in Python 3, where it raises a SyntaxError. Python 2 has _many_ quirks like this one. Python 3 was not just "it's unicode".
- bcrack 8y agoActually Python 2 allows that, in Python 3 True, False, and None are reserved words [1]. [1] https://docs.python.org/3/whatsnew/3.0.html#changed-syntax https://docs.python.org/3/whatsnew/3.0.html#changed-syntax
- cesarb 8y agoLuckily, assigning to True and False affects only the current module. If he had changed __builtins__.True and __builtins__.False, on the other hand... (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.)