Comments in Python

SzintaxisVáltozók

Comments are notes in your code that Python ignores when running the program. They explain what the code does, making it easier to understand and maintain.

Good comments are essential for collaboration and for your future self.

Single-Line Comments

Start with # – everything after it on the line is ignored.

Multi-Line Comments

Python doesn't have a special syntax – use multiple # lines or triple quotes (often used for docstrings).

Docstrings – Documentation Strings

Triple quotes right after a function/class/module define a docstring – accessible via help() or __doc__.

When to Use Comments

  • Explain why code does something (not just what).
  • Document functions/classes with docstrings.
  • Temporarily disable code during testing.
  • Add TODO notes or section headers.

Avoid commenting obvious code – focus on clarity.

Quick Quiz

Az anyagokat átnéztük és ellenőriztük, de hibák továbbra is előfordulhatnak. A tartalom kizárólag oktatási célt szolgál, ezért saját felelősségre használd, és szükség esetén ellenőrizd más forrásokkal is.

✨ Kérdezd Larát — a tanulási partnered

Fedezd fel a személyre szabott tanulási támogatást. Lara elmagyarázza az anyagot, összefoglalja a témákat és megválaszolja a kérdéseidet — az Go csomagtól elérhető.


Lara segít gyorsabban tanulni — kizárólag a ReadyTools Go, Plus és Max tagoknak.

Kövesd nyomon a fejlődésed 🚀

Tanulj egyszerűbben utad nyomonkövetésével teljesen ingyen.