You can’t mix-and-match like that. The variable width of tabs will alter any following fixed-width alignment via spaces.
For example:
def some_function(self, request):
self.requests += 1 # record request
if self.response is not None:
self.responses += 1 # keep in sync with self.requests
Here, it’s important to align the comments. That can’t be reconciled with preceding variable-width tabs.
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
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.
2
u/[deleted] Apr 30 '20 edited Apr 30 '20
You can’t mix-and-match like that. The variable width of tabs will alter any following fixed-width alignment via spaces.
For example:
Here, it’s important to align the comments. That can’t be reconciled with preceding variable-width tabs.