Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
comment indentations
#11
(Jan-27-2017, 09:21 AM)buran Wrote: these are exactly block comments as described in PEP8

they didn't make it clear if that was their intent.

based on their definition, what does a non-block comment look like?

(Jan-27-2017, 09:36 AM)ichabod801 Wrote: ... I have always indented by comments to match the level of indentation of the code. I've been inconsistent with if/then statements, though. Sometimes the comment feels like it goes with the condition, sometimes it feels like it goes with the indented code.

mostly i have done that.  there are some cases (in C coding i have done before) where the comments look better not indented at all, often by fitting across the whole line.  these a sometime complex comments with tables ad graphs and such.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#12
(Jan-28-2017, 02:18 AM)Skaperen Wrote: they didn't make it clear if that was their intent.

based on their definition, what does a non-block comment look like?

Well, it's clear that block in block comment refer to block of code not block of comment lines (multi-line comment). Opposite to inline comments.
I don't know where "non-block comment' comes from or what it is supposed to mean. there is no such term used in PEP8.
Reply
#13
well, in any case, the consensus seems to be that the comments should have the same indentation as the code they are commenting about, generally right below the comment.  thus each will have the same number of spaces (and no tabs) up to the first non-white-space character.  comments are not an excuse to use tabs in the file.  if the comments need spacing, it shall be done with space characters.

going beyond PEP8.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to add multi-line comment section? Winfried 1 139 Mar-24-2024, 04:34 PM
Last Post: deanhystad
Question remove all comment ? SpongeB0B 7 1,191 Oct-27-2023, 05:40 PM
Last Post: deanhystad
  Regular Expression search to comment lines of code Gman2233 5 1,594 Sep-08-2022, 06:57 AM
Last Post: ndc85430
  Block comment in Intellij kam_uk 2 2,253 Nov-15-2020, 05:22 PM
Last Post: kam_uk
  Python 3 Elementtree and Comment First gw1500se 3 3,661 May-25-2020, 09:02 PM
Last Post: gw1500se
  Indentations macfanpl 10 4,060 Apr-27-2020, 02:31 PM
Last Post: buran
  Youtube Comment bot mateusz135 4 58,733 Mar-14-2020, 04:18 PM
Last Post: buran
  pdb says "SyntaxError: unexpected EOF" on comment pwannh 1 3,036 Nov-29-2018, 04:17 PM
Last Post: nilamo
  Help extracting comment data from multiple zip files SoulsKeeper 10 6,030 Sep-10-2018, 10:33 AM
Last Post: SoulsKeeper
  python crontab remove_all(comment="Minute*") vvarrior 1 2,738 Aug-06-2018, 12:39 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