python comments code example
Example 1: python comments
# this is a comment
# Python ignores comments,
something = 1 # and you can place them after any line of code
"""If you don't want to write a comments using hashtags,
you can put them in a multi-line comment block.
However, if you put hashtags in strings, they do not
create comments.
"""
# comments serve as notes to the programmers
# you can write whatever you want in comments
Example 2: python comments
# Numpy-style python comments for functions
def foo(param_1=True):
"""Example function.
Parameters
----------
param_1 : bool, optional
The first parameter (default is True)
Returns
-------
num
a number
"""
return -1
Example 3: python comments
# this is a single line comment, python ignores these
foo = "bar" # can be placed after code
"""
python doesnt have multiline comments
so multiline strings do the tricks
this works because python ignores string literals that arentassigned to a varaible
"""
# comments can be used as notes for the dude editing the script
Example 4: python comments
# this is a python comment
Example 5: python comments
# This is a single lined comment for Python,
# and can be used at the end of a line of code
"""
For multi-line comments,
use three hashtags! can not go in the end of a line of code.
""" # make sure to close your comment!
Example 6: python comments
#This is a comment