Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7962241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:17:05+00:00 2026-06-04T05:17:05+00:00

In python to comment-out multiple lines we use triple quotes def x(): This code

  • 0

In python to comment-out multiple lines we use triple quotes

def x():
   """This code will 
      add 1 and 1 """
   a=1+1

but what if I have to comment out a block of code which already contains lot of other comment out blocks (triple quote comments). For example if I want to comment out this function fully..

"""
def x():
   """This code will 
      add 1 and 1 """
   a=1+1
"""

This doesn’t work. How can I comment out such blocks of code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T05:17:06+00:00Added an answer on June 4, 2026 at 5:17 am

    In python to comment-out multiple lines we use triple commas

    That’s just one way of doing it, and you’re technically using a string literal, not a comment. And, although it has become fairly established, this way of writing comments has the drawback you observed: you cannot comment out nested blocks.1

    Python doesn’t have nesting multiline comments, it’s as simple as that. If you want to comment out multiple lines allowing for nested comments, the only safe choice is to comment out each line.

    Most editors have some command that makes commenting out or in multiple lines easy.


    1 For a single level of nesting you can in fact use '''"""nested """''', or the other way round. But I wouldn’t recommend it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to comment out lines in some code I have. I have different
What is the shortcut to comment out multiple lines with Python Tools for Visual
Is there a mechanism to comment out large blocks of Python code? Right now,
For the following Python 2.7 code: #!/usr/bin/python def func_a(): print "func_a" c = 0
I have a python app engine code (matured backend) - and we are now
I think I finally figured out they need to use this DeclarativeFieldsMetaclass (to turn
This is probably a simple question, but it's driving me crazy! I have a
When I try this code: a, b, c = (1, 2, 3) def test():
I have looked at the following question: How to comment out a block of
I program Django/Python in emacs, and I would like things like {% comment %}

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.