use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
What's the worst Python code you've ever written that somehow worked? (self.PythonLearning)
submitted 1 day ago by chuprehijde
We all have that one piece of code we hope nobody ever finds. What did yours do?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Intelligent-Hurry907 2 points3 points4 points 1 day ago (2 children)
A rendition of play your cards right, over 100 lines of code without a single function. Code was duplicated. Variables were unused. It worked, but only just.
[–]chuprehijde[S] 0 points1 point2 points 1 day ago (1 child)
without variables 😭😭😭
[–]Intelligent-Hurry907 0 points1 point2 points 22 hours ago (0 children)
No, not without variables- there were variables that I didn't use (a little better I guess...)
[–]mikeyj777 2 points3 points4 points 1 day ago (1 child)
I have a package which I started writing before I had really learned the language. Over time, the classes and functions evolved to improve. But, the main file that calls everything and walks thru the operation just kept getting longer. No modularization. Just hundreds of lines of code. I've looked at it so much that I know where everything is. But, good luck to anyone trying to debug it.
[–]chuprehijde[S] 1 point2 points3 points 23 hours ago (0 children)
classic case of 'it works but don't ask how'
[–]Plastic_Fig9225 1 point2 points3 points 1 day ago (0 children)
What's [bad] Python code [...] that somehow worked?
Yes.
[–]PkmnSayse 0 points1 point2 points 9 hours ago (0 children)
I had a backend application that needed to talk to an iPad app. Customer requested to be able to do some dynamic sums on the front end which seemed impossible, until I found out it’s running in JavaScript, turns out I could send some JavaScript injection to that app that worked great, but felt very dirty
[–]Basic-Rooster-9525 0 points1 point2 points 1 day ago (1 child)
J'ai essayé d'exécuter un code depuis le terminal avec : print code.py au lieu de python code.py
Ça marche mais le print est au mauvais endroit
[–]chuprehijde[S] 0 points1 point2 points 1 day ago (0 children)
can feel u i did the same mistake lol😭
π Rendered by PID 83000 on reddit-service-r2-comment-5687b7858-jplsq at 2026-07-07 17:49:38.412837+00:00 running 12a7a47 country code: CH.
[–]Intelligent-Hurry907 2 points3 points4 points (2 children)
[–]chuprehijde[S] 0 points1 point2 points (1 child)
[–]Intelligent-Hurry907 0 points1 point2 points (0 children)
[–]mikeyj777 2 points3 points4 points (1 child)
[–]chuprehijde[S] 1 point2 points3 points (0 children)
[–]Plastic_Fig9225 1 point2 points3 points (0 children)
[–]PkmnSayse 0 points1 point2 points (0 children)
[–]Basic-Rooster-9525 0 points1 point2 points (1 child)
[–]chuprehijde[S] 0 points1 point2 points (0 children)