Python Forum
How to add multi-line comment section?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to add multi-line comment section?
#1
Edit (since this forum doesn't support deleting a thread): My mistake. After using the (shift+)TAB keys, the script runs. Guess there were useless TAB characters.

-----------------

Hello,

Is there a way to add a multi-line comment block that keeps Python happy?

import glob

for item in glob.glob("*.txt"):
	print(f"**************** Handling {item}")

	name = True
	if name:
		print("True1")
	else:
		print("False1")

  #=========== blah
  """ IndentationError: unindent does not match any outer indentation level
  some
  comment
  """
	if name:
		print("True2")
	else:
		print("False2")
Note: Unlike displayed above, in the source code, the block is at the same level as the two "if name" lines.

Thank you.
Reply
#2
Output:
""" This is a multi-line string that you can use as a comment. """ def some_func(): """I am often used to document a function, even if I am only one line."""
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question remove all comment ? SpongeB0B 7 1,381 Oct-27-2023, 05:40 PM
Last Post: deanhystad
  Regular Expression search to comment lines of code Gman2233 5 1,702 Sep-08-2022, 06:57 AM
Last Post: ndc85430
  regex multi-line kucingkembar 6 1,585 Aug-27-2022, 10:27 PM
Last Post: kucingkembar
  Append data to Yaml section tbaror 0 7,008 Feb-09-2022, 06:56 PM
Last Post: tbaror
  multi-line CMD in one-line python kucingkembar 5 4,002 Jan-01-2022, 12:45 PM
Last Post: kucingkembar
  Multi-line console input lizze 4 2,383 Dec-26-2020, 08:10 AM
Last Post: lizze
  Block comment in Intellij kam_uk 2 2,308 Nov-15-2020, 05:22 PM
Last Post: kam_uk
  Python 3 Elementtree and Comment First gw1500se 3 3,758 May-25-2020, 09:02 PM
Last Post: gw1500se
  Youtube Comment bot mateusz135 4 69,538 Mar-14-2020, 04:18 PM
Last Post: buran
  Create an isolated section in bash? yxk 1 1,961 Feb-27-2020, 11:16 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020