Talk to Your Future Self
The problem...
You write code. It works. You close the file.
Two weeks later you open it again. And you have no idea what it does or why.
This happens to everyone. Even experienced developers.
The idea!
Comments are lines in your code that Python ignores completely.
They're not for Python. They're for you. And for anyone else who reads your code.
Making it real
A comment starts with #. Everything after it on that line is ignored.
# This is a comment — Python ignores this line
name = "Bull" # This is an inline comment
Python sees name = "Bull". The rest doesn't exist for it.
In practice
# Ask the user for their name and age
name = input("Enter your name: ")
age = int(input("Enter your age: "))
# Calculate birth year
birth_year = 2025 - age
# Print the result
print(f"{name} was born in approximately {birth_year}.")
The code does the same thing with or without comments.
But with comments, anyone — including future you — knows exactly what's happening and why.
Going further
Comments are also useful for temporarily disabling code without deleting it.
name = "Bull"
# print(name) # disabled — won't run
print("Done")
This is called commenting out. You'll use it constantly while debugging.
What's really happening
Python reads your file line by line. When it sees #, it skips everything after it on that line.
No performance cost. No side effects. Just silence.
Heads up!
- Comments don't slow down your program — Python ignores them completely
- A comment explains why, not what — the code already shows what
- Don't over-comment —
# prints nameaboveprint(name)adds nothing - Comment when the logic isn't obvious — not every single line
The mindset shift
Stop thinking: "Comments are extra work."
Start thinking: "Comments are a letter to your future self. Write them well."
What you should understand now
- Comments start with
#— Python ignores them - They're for humans, not for Python
- Use them to explain why, not what
- Commenting out code is a useful debugging tool