By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,426 Members | 1,729 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,426 IT Pros & Developers. It's quick & easy.

how to comment out a block of code

P: n/a
is there a syntax to comment out a block of code? i.e. like html's <!--
comment -->
or perhaps put a marker so that all lines from there on are ignored?
thanks.

Xah
xa*@xahlee.org
http://xahlee.org/PageTwo_dir/more.html

Jul 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
A bit of a hack of course, but you can enclose the code that should be
commented out with ''' and ''' or """ and """ (not sure about the name of
this tripple-quoting)
OTOH, some (or even most if not all) Python editors support blockquoting
by pushing a button or using shortcuts. SPE and IDLE for example.

Jul 18 '05 #2

P: n/a
Xah Lee wrote:

is there a syntax to comment out a block of code? i.e. like html's <!--
comment -->
or perhaps put a marker so that all lines from there on are ignored?
thanks.


The simplest way is to select the block of code in your editor and use the
'comment-region' command. If this doesn't work, upgrade your editor.

Most editors have a command to do this although obviously the name will
vary slightly: Idle calls it 'Comment Out Region', SciTe calls it 'Block
Comment', emacs calls it 'comment-region'.
Jul 18 '05 #3

P: n/a
Xah Lee wrote:
is there a syntax to comment out a block of code? i.e. like html's <!--
comment -->
or perhaps put a marker so that all lines from there on are ignored?
thanks.


Of course -- this feature is so important that all computer
manufacturers worldwide have made a special button on the computer
case just for this!

Normally it's a large round button, with perhaps a green backlight.
Press the button and hold it in for about 3 seconds, and the rest of
your code/writing will be ignored just as it should be.

Jeff Shannon
Technician/Programmer
Credit International

Jul 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.