Beginner Python Concepts

a-Rye
45K views

Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content

Comments

Comments are very useful in programming. If you're coding for work or to be published, you'll want to explain your code with comments. You can also use comments in debugging to investigate your code further.

# This is a single line comment. Any line that starts with a # will be seen as a comment by the compiler / interpreter / computer. 

'''
This
is
a
multi
line
comment
'''

"""
This
is
also
a 
multi
line
comment
"""

# It gets a weird value here, still not sure why?

Disabling parts of your code

Sometimes, you just want a part of your code to stop temporarily. I often find myself doing this when trying to optimize my code or when trying to single out a corner case in my code.

Let's take that mass of code from the previous page and try looking at each piece individually.

Try "turning pieces on and off again"!
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content