About 8,850,000 results
Open links in new tab
  1. What is the proper way to comment functions in Python?

    Dec 14, 2019 · String literals occurring elsewhere in Python code may also act as documentation. They are not recognized by the Python bytecode compiler and are not accessible as runtime object attributes (i.e. not assigned to __doc__ ), but two types of extra docstrings may be extracted by software tools:

  2. How do I create multiline comments in Python? - Stack Overflow

    Apr 9, 2022 · Among other answers, I find the easiest way is to use the IDE comment functions which use the Python comment support of #. I am using Anaconda Spyder and it has: Ctrl + 1 - Comment/uncomment; Ctrl + 4 - Comment a block of code; Ctrl + 5 - Uncomment a block of code; It would comment/uncomment a single/multi line/s of code with #. I find it the ...

  3. What is the proper way to comment code in Python? [closed]

    I don't know if this represents the "community standard" but here are Google's Python style guides (as they relate to comments). Specifically classes: Specifically classes: class SampleClass(object): """Summary of class here.

  4. How to comment out a block of code in Python [duplicate]

    Python does not have such a mechanism. Prepend a # to each line to block comment. For more information see PEP 8. Most Python IDEs support a mechanism to do the block-commenting-with-hash-signs automatically for you. For example, in IDLE on my machine, it's Alt+3 and Alt+4.

  5. How to write an inline-comment in Python - Stack Overflow

    Dec 14, 2019 · Whitespace in Python is too important to allow any other kind of comment besides the # comment that goes to the end of the line. Take this code: x = 1 for i in range(10): x = x + 1 /* Print. */ print x Because indentation determines scope, the parser has no …

  6. python - Comment/Uncomment multiple lines in …

    May 12, 2021 · I was wondering, if there is a PRO way of commenting/removing multiline # comments in JupyterNotebooks. # line1 # line2 # line3 Something like SHIFT + " for adding triple quotes.

  7. python - comment out nested triple quotes - Stack Overflow

    May 21, 2012 · 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..

  8. Shortcut key for commenting out lines of Python code in Spyder

    Apr 15, 2016 · Unblock multi-line comment. Ctrl+5. Multi-line comment. Ctrl+4. NOTE: For my version of Spyder (3.1.4) if I highlighted the entire multi-line comment and used Ctrl+5 the block remained commented out. Only after highlighting a small …

  9. python - Proper use of comments - Stack Overflow

    Sep 23, 2017 · Python PEP8 has a section on comments. In short: Use inline comments sparingly. An inline comment is a comment on the same line as a statement. Inline comments should be separated by at least two spaces from the statement. They should start with a # and a single space. Inline comments are unnecessary and in fact distracting if they state the ...

  10. How can I comment multiple lines in Visual Studio Code?

    This is probably not the top voted answer because of how VS Code works for different languages. For python code, the "comment block" command Alt + Shift + A actually wraps the selected text in a multiline string, whereas Ctrl + / is the way to toggle any type of comment (including a "block" comment as asked here). –

Refresh