r/badcode • u/Nilstrieb • Sep 05 '21
python Found this in the code where I tried out python for the first time (I did know other languages then)
1.5k
Upvotes
r/badcode • u/Nilstrieb • Sep 05 '21
277
u/metalovingien Sep 05 '21
You clean your clean white walls with whitening stuff, don't you ?
6
u/sixtyfifth_snow Sep 06 '21
At least the font looks sharp, I like it BTW.
5
u/heyshikhar Sep 06 '21
That font is looking crisp.
87
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Sep 05 '21
Image Transcription: Code
I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
59
u/Jackarduino Sep 05 '21
I first tried python 2 month ago and ive made this kind of error at the time
44
u/jjman72 Sep 05 '21
The is the exact opposite of spaghetti code. Nice and concise. :-)
21
u/Isvara Sep 05 '21
Maybe they got confused about what "explicit is better than implicit" actually meant.
7
u/Silly-Freak Sep 05 '21
Ah yes, this result is made from result
8
u/CalligrapherThese606 Sep 05 '21
it takes extreme amount of bravery to admit something like that.:''''))
11
u/v_maria Sep 05 '21
i sometimes do stuff like this because it's easy way to set a break point
1
u/High_Quality_Bean Sep 05 '21
A little bit of cleaning up and you'd almost have an Option from Rust. You return an Option whenever you'd feel the need to return a null value, making it explicit. It can take the values "Some" (holding the return value) or "none" (a null value).
6
u/[deleted] Sep 05 '21
I dont get it. It does nothing
2
u/GergiH Sep 06 '21
Whoever says they never did this, they're lying.
2
u/PraiseTheOof Sep 06 '21
Finally! I found one where I actually understand why it's bad!
1
u/acos12 Sep 05 '21
Bad code? This is basically the Mother of all Code.
1
u/[deleted] Sep 05 '21
My boss ripped into me for writing this once...
1
u/bw984 Sep 06 '21
Hey I know the exact intent on first read through. I’d probably not even request it be changed in a code review if you were a jr. dev. If it works and is easy to understand the offense is minor at best.
1
u/stahkh Sep 06 '21
Is there anyone who doesn't have brainfarts like this? Being tired, distracted or whatever can easily bring you to writing your thought process in the most verbose way possible.
1
u/Masterpommel Sep 06 '21
Its like the compiler is still a child and you have to explain it properly to him so he doesnt make mistakes.
1
u/Kyyken Sep 06 '21
still waiting for them to implement the don't keyword so python becomes fully compatible with English
-35
u/Knuffya Sep 05 '21
Why would you use python when you know other languages?
-7
u/kgro Sep 06 '21
The code is not wrong. It’s useless, but not wrong. Just not very pythonic. Can be improved by:
or
depending what you were going for
0
u/[deleted] Sep 05 '21
[deleted] — view deleted comment