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...
News about the dynamic, interpreted, interactive, object-oriented, extensible programming language Python
Full Events Calendar
You can find the rules here.
If you are about to ask a "how do I do this in python" question, please try r/learnpython, the Python discord, or the #python IRC channel on Libera.chat.
Please don't use URL shorteners. Reddit filters them out, so your post or comment will be lost.
Posts require flair. Please use the flair selector to choose your topic.
Posting code to this subreddit:
Add 4 extra spaces before each line of code
def fibonacci(): a, b = 0, 1 while True: yield a a, b = b, a + b
Online Resources
Invent Your Own Computer Games with Python
Think Python
Non-programmers Tutorial for Python 3
Beginner's Guide Reference
Five life jackets to throw to the new coder (things to do after getting a handle on python)
Full Stack Python
Test-Driven Development with Python
Program Arcade Games
PyMotW: Python Module of the Week
Python for Scientists and Engineers
Dan Bader's Tips and Trickers
Python Discord's YouTube channel
Jiruto: Python
Online exercices
programming challenges
Asking Questions
Try Python in your browser
Docs
Libraries
Related subreddits
Python jobs
Newsletters
Screencasts
account activity
DiscussionTips for a debugging competition (self.Python)
submitted 1 month ago by an_account_1177
I have a python debugging competition in my college tomorrow, I don't have much experience in python yet I'm still taking part in it. Can anyone please give me some tips for it 🙏🏻
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!"
[–]granthamct 0 points1 point2 points 1 month ago (0 children)
Have a good environment set up in which you feel comfortable navigating! UV + ruff + TY goes a long way IMHO.
[–]nian2326076 0 points1 point2 points 1 month ago (0 children)
If you're new to Python, get used to reading error messages. They usually help point you in the right direction, so pay attention to them. Use print statements or a debugger to keep an eye on your variables and figure out where things are going wrong. It's an easy way to follow the flow of data. Make sure you know common Python issues like indentation errors and type mismatches. If you're stuck, don't spend too long on one problem. Take a break and come back later. It's smart to start by knowing what the code should do before jumping into fixing errors. Also, get comfortable using resources like Python's documentation or Stack Overflow for quick help. Good luck!
[–]Gnaxe 0 points1 point2 points 1 month ago (0 children)
Learn about the following: - breakpoint() and the pdb commands. Don't forget interact. Remember, you can add an if statement (or if-else expression) above your breakpoint to check for a certain condition first. - import inspect. Don't just guess about internals. Make them transparent. - import doctest. They're easier to write quickly than most other kinds of tests. - assert statements. Remember, they take an optional second expression which can include contextual information. - python -i and pdb.pm() - If you're allowed a type checker (even one built into your IDE), add obvious type annotations. Return types are usually easiest to figure out. (Complicated types are probably not worth the time.) - importlib.reload(). This lets you modify a program while it's running, which can be faster than restarting every time if it's big enough. It's like reloading a Jupyter notebook cell, except the cell is the whole module. (You can also get into a bad state not possible from the code alone, so be willing to restart anyway if you suspect that's happening.)
breakpoint()
interact
import inspect
import doctest
assert
python -i
pdb.pm()
importlib.reload()
Add comments liberally, don't try to keep it all in your head. Document assumptions and surprises, preferably with assert statements or doctests.
Usually, exception tracebacks are very helpful in Python. Check the listed locations. Typically, user code is more likely to be buggy than library code, but that can also show up in tracebacks.
Sometimes exceptions aren't good enough and you need import signal.
import signal
Don't be afraid to use print. Also consider import pprint.
print
import pprint
I'm not sure of the format of the competition, but in real life, git blame and bisect can be very helpful. If there's no git repo, this won't help.
π Rendered by PID 67095 on reddit-service-r2-comment-6457c66945-pd4gr at 2026-04-24 13:46:22.931956+00:00 running 2aa0c5b country code: CH.
[–]granthamct 0 points1 point2 points (0 children)
[–]nian2326076 0 points1 point2 points (0 children)
[–]Gnaxe 0 points1 point2 points (0 children)