r/itsaunixsystem • u/AnAngryBanker • Oct 14 '24
[Nightsleeper] Some horrible, unindented python code to slow down a train
- no indentation
- multiple nested try blocks with seemingly no except
- stray " in the middle of that string
- input's argument should be something written to the prompt
- even if it wasn't you'll struggle to turn that into an int
- you probably want to be passing in that speed variable somewhere, right?
+1 for sanitising the speed I guess, wouldn't want the train to start moving backwards.
503
Upvotes
50
u/Ilix Oct 14 '24
Does Python not show an error for the stray quote, or is this just not in an editor with errors displayed?
3
u/Xerxero Oct 15 '24
Why do I need a str first only to cast it into an int?
202
u/carenrose Oct 15 '24
Ah yes, I prefer to write code in a word doc with double-spacing and using Times New Roman
18
u/opello Oct 15 '24
I had to suspend some significant disbelief for this part. At least the little Pi shield was a real cellular modem board. Props to the ... prop ... department for that.
13
u/lujangba Oct 15 '24
I love that, trying to stop a train in an emergency, the developer commented his code.
5
u/JustPlainRude Oct 15 '24
That's a unique quoting style
66
u/aezart Oct 14 '24
I cannot believe python actually allows this syntax, jesus
4
u/Specified_Owl Nov 14 '24
"try"?
Do while or Do not.
2
u/etamatulg Feb 21 '26
This show deserved several threads :D
I know for sure that they'll have had an actual IT consultant draft up the concepts and then some script editor came along and dumbed it down for the public. Once scene they said the code was "camouflaged" when we know the original word would be "obfuscated" but the public wouldn't understand that frequently enough.
1
u/EasternPen1337 Jan 24 '25
I hate indentation but I hate this more