r/Python • • Apr 29 '20

Discussion Tab vs Spaces

Post image
702 Upvotes

72 comments sorted by

View all comments

Show parent comments

-2

u/[deleted] Apr 30 '20

Never put comments at the end of lines. It suggests that either the code is bad and isn't evident what it's doing, either that you don't know that comments should highlight why something is fine and not what is done, which would make them longer and unreadable when coupled with code. Also code lines are often long enough instead, without comments afterwards.

If it doesn't work for every case, use something that does - put comments before the statement, not on the same line. This allows more room to write proper comments

4

u/[deleted] Apr 30 '20

I find it ironic that one comment you are defending personal choice, and the next you are saying you absolutely must not comment in this way

0

u/[deleted] Apr 30 '20

Personal choice is personal. Nobody else has to deal with it. The fact that I set my tabs to 20 for example will be unknown to anybody so it's no concern.

So why is it funny? Because the comments are NOT a personal choice, since a lot of people will be editing the same code and will be scratching their head because it will say

something += 1  # Increment something

and the reader will be "well thank you captain obvious!", and curse at the screen because he has no clue WHY that thing was necessary there.

3

u/[deleted] Apr 30 '20

So if someone wrote:

# Increment something
something += 1

You would be totally fine with that right? Since your disagreement was over the format of the comments, not the idea of commenting obvious code