Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: commenting out blocks of code

Reply
Thread Tools

Re: commenting out blocks of code

 
 
Paul McNett
Guest
Posts: n/a
 
      02-18-2006
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


 
Reply With Quote
 
 
 
 
Cameron Laird
Guest
Posts: n/a
 
      02-18-2006
In article <mailman.2076.1140221235.27775.python->,
Paul McNett <> 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: """.

'''
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: commenting out blocks of code Peter Hansen Python 8 02-20-2006 12:42 AM
Re: commenting out blocks of code Jean-Paul Calderone Python 0 02-18-2006 02:09 AM
Commenting out VB code =?Utf-8?B?U2FuZHk=?= ASP .Net 5 02-03-2005 05:51 PM
procs/blocks - blocks with procs, blocks with blocks? matt Ruby 1 08-06-2004 01:33 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57