Comments are in the source code for humans to read, not for computers to execute. that has to be overhead that is unneeded for a comment. Case in point: if you had ''' /NPF ''' and run that in Python 3, it will throw a syntax error. site design / logo © 2020 Stack Exchange Inc; user contributions licensed under A string literal is what we see in the source code of a computer program, including the quotation marks. If you switch to # and comment the line, it is skipped. Except the person who chooses to defy this definitive answer by using it to mean something else. You can use ''' foo ''' for docstrings and """ bar """ for comments or vice-versa to make the code more readable.Another editor-based solution: text "rectangles" in Emacs. It is not the best practice though. Sorry. The Overflow Blog It’s important!For Python training, our top recommendation is DataCamp. That's a clever idea, though it may mean that the comments need comments :)That solution is similar to just commenting out the code, except that you add four spaces instead of # and that you also need to add "if False:" line.I was doing some script hacking and that is what I came up with. This is just one example. Note that the code will still need to have proper syntax.At least in VIM you can select the first column of text you want to insert using Block Visual mode (Incidentally, Notepad++ works nicely as a Python editor. your coworkers to find and share information. (17 answers) You can comment out block of code or multiple lines by using three single quotes before and after the code like this: [code]''' this is commented out. For example, this is a rather useless comment: The next example shows a more helpful comment, instead, and goes along with giving variables obvious names: There are an infinite number of other scenarios that warrant comments. It's called 'flexibility'. Philosophical question: what is a thorpe?Clearly, all Real Python Programmers use ed, where this problem is easily solved with: 12,31s/^/#/vim with nerdcommenter. Stack Overflow for Teams is a private, secure spot for you and

Most Python IDEs support a mechanism to do the block-commenting-with-pound-signs automatically for you.

They should always be short, straight to the point, and add informative value. Stack Overflow works best with JavaScript enabled Strangely enough, I asked the original question for a friend, wanting to show off S.O. For example, in IDLE on my machine, it's Alt+3 and Alt+4. This details what certain parts of the code are for, and lets other developers – you included – know what you were up to when you wrote the code. Generally, comments will look something like this: Because comments do not execute, when you run a program you will not see any indication of the comment there. Comments in Python begin with a hash mark (#) and whitespace character and continue to the end of the line. print(2*3) ''' [/code]Its output is like: [code]'\nthis is commented out.\nprint(2*3)\n' [/code] Featured on Meta This one asks for a solution, while the other one takes the answer (namely that no, there's no solution) as a prerequisite for asking what it has to ask.Perl allows you to use the documentation syntax for block commenting in such a way that it does NOT end up in the documentation. For example, if you wrote a complex regex, you add a comment describing what the code does.


Free 30 Day Trial And '*' is a hexathorpe, '+' is a quadrathorpe, and '-' is a duothorpe. The string value is what we see as the output in a terminal … Please stop using local slang terms - few Americans call it a hash, and few non-Americans call it a pound, but nobody ever refers to anything else when they say octothorp. The (“””) method isn’t actually a comment but defines a Text constant of the text between the (“””).