![]() |
Re: commenting out blocks of code
john peter wrote:
> in java, i can prevent a block of code from executing > by bracketing the block with comment indicators, as shown > below: > /* > statement1 will not execute; > statement2 will not execute; > */ > statement3 will execute > > is there a similar mechanism in python, other than prefixing > the '#' character to the start of each statement i do not > want to execute (which gets old very quickly if one needs to > comment and uncomment several statements a couple of > times while "playing around with code" say during initial design)? IMO this is a missing feature in Python. However, if the block of code you are wanting to comment out doesn't happen to contain any triple-quotes, you can surround the code with those. For example: def myFunc(arg): return arg + 2 """ def myFunc(arg): return arg + 1 """ >>> print myFunc(2) 4 -- Paul |
Re: commenting out blocks of code
In article <mailman.2076.1140221235.27775.python-list@python.org>,
Paul McNett <p@ulmcnett.com> wrote: . . . >IMO this is a missing feature in Python. However, if the block of code >you are wanting to comment out doesn't happen to contain any >triple-quotes, you can surround the code with those. For example: > >def myFunc(arg): > return arg + 2 > >""" >def myFunc(arg): > return arg + 1 >""" > > >>> print myFunc(2) >4 . . . .... and note that, even if the block *does* contain triple-quotes of one flavor, you can use the other: '''This is syntactic data: """. ''' |
| All times are GMT. The time now is 11:25 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.