6 ms·
>but I have never been so utterly _disoriented_ by bad code One of these days, when the mood strikes, I'll upload the matlab script I inherited from my Ph.D su
by omginternets 8y ago
>but I have never been so utterly _disoriented_ by bad code
One of these days, when the mood strikes, I'll upload the matlab script I inherited from my Ph.D supervisor.
Scientific programming is, by and large, an abysmal state of affairs.
- Waterluvian 8y agoAt one job I had we got "help" from a local college professor on how to design our database. A lot of what he said made sense. And we were super green and databases were not our expertise or focus. Short on time, high on cash, we asked if he'd implement it for us. I will never forget my gut wrenching feeling when I opened up one of the main provisioning scripts (in Python) to read the first two lines: True = 0 False = -1 The rest of it was an unmaintainable disaster that may have worked. I learned so much that summer, having been forced to learn it all myself.
- djtriptych 8y agoI literally almost choked on my drink reading this.
- felipemnoa 8y ago>>I will never forget my gut wrenching feeling when I opened up one of the main provisioning scripts (in Python) to read the first two lines: 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.
- kpcyrd 8y ago>>> True = 0 >>> False = -1 >>> if False: print('oh no') False is now truthy and True is falsey. Note this only works in python2.
- wingerlang 8y agoTrue is normally 1, while False is 0. This seems like specific variable declarations as well, which you generally don't need as they are built into all languages e.g. "variable = false;" 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.
- Buge 8y agoIn 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. :)
- rgacote 8y agoTrue != Success
- 8y ago
- fyi1183 8y agoThat's a nice story, but True and False are keywords in python. Such assignment attempts are a syntax error.
- haldean 8y agoThis was not true in Python 2, and redefining True to False used to be a jokey way to break the interpreter in a bunch of fun ways.
- jwilk 8y agoIn fact, there's still lots of code in the wild that assigns to True/False, presumably for compatibility with very old Python versions: https://codesearch.debian.net/search?q=%28%3Fm%29%5E%5Cs%2ATrue%5Cs%2A%3D+filetype%3Apython https://codesearch.debian.net/search?q=%28%3Fm%29%5E%5Cs%2AT...
- nazri1 8y agohttps://thedailywtf.com/articles/What_Is_Truth_0x3f_ https://thedailywtf.com/articles/What_Is_Truth_0x3f_