how to comment out a block of code

Discussion in 'Python' started by Xah Lee, Jan 26, 2005.

  1. Xah Lee

    Xah Lee Guest

    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

    http://xahlee.org/PageTwo_dir/more.html
     
    Xah Lee, Jan 26, 2005
    #1
    1. Advertising

  2. 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.
     
    Christian von Essen, Jan 26, 2005
    #2
    1. Advertising

  3. Xah Lee

    Duncan Booth Guest

    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'.
     
    Duncan Booth, Jan 27, 2005
    #3
  4. Xah Lee

    Jeff Shannon Guest

    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
     
    Jeff Shannon, Jan 27, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alec S.
    Replies:
    10
    Views:
    10,172
    Alec S.
    Apr 16, 2005
  2. Roseanne Zhang

    Can ruby comment out a block of code???

    Roseanne Zhang, Oct 14, 2006, in forum: Ruby
    Replies:
    5
    Views:
    143
    David Vallner
    Oct 15, 2006
  3. Dan Jacobson
    Replies:
    2
    Views:
    143
    Dan Jacobson
    Sep 20, 2003
  4. PerlFAQ Server
    Replies:
    0
    Views:
    118
    PerlFAQ Server
    Feb 3, 2011
  5. PerlFAQ Server
    Replies:
    0
    Views:
    185
    PerlFAQ Server
    Apr 16, 2011
Loading...

Share This Page