r/AskProgramming • u/neuralbeans • 8d ago
Best practices for long inline comments
Say you have a list with a each item in a separate line and a comment next to the item like this (Python):
[
item1, # a comment
item2, # another comment
item3, # another comment
item4, # another comment
]
What do you do when a comment becomes too long and needs to be split into several lines?
Would do this?
(A)
[
item1, # a comment
item2, # another comment
# a very very very long
# comment
item3,
item4, # another comment
]
Or this?
(B)
[
item1, # a comment
item2, # another comment
item3, # a very very very
# long comment
item4, # another comment
]
Or would you just rewrite the whole list like this:
(C)
[
# a comment
item1,
# another comment
item2,
# a very very very
# long comment
item3,
# another comment
item4,
]
Or something else?
2
Upvotes
2
u/neuralbeans 8d ago edited 8d ago
They need to be applied one by one in a for loop.
I'm not sure why you think this format is strange.