Line Comments
Line comments in Python are very simple. The # character denotes that everything afterward on that line is a comment.
1 2 |
#here is a whole-line comment for some code x = 3 #this comments code on the current line |
Block Comments
Unfortunately, there is no specific syntax for block comments in python. To comment a block of code, you must simply place a # before every line in the block of code you wish to comment. Many Python IDE's, however, provide a simple way to comment out a block of code. A tricky way of quickly block-commenting a large block of code is to prefix the block with if False: and then indent the block to be commented. Just remember un-indent and delete the conditional afterward!





