But you don’t explain the numbers, you explain what the function does or rather, what are each individual fields in your money list is. Essentially you are providing documentation of your data structure in the implementation details of it. It isn’t explained in the comments why dollars are 5000000 and the others are only 500, it also doesn’t state if there are any dependency between them. Is the fact that the other currencies are 500 dependent on the fact that dollars are 5000000? Are they incremented together or always independently? There are lot of information here that could be in the comments and are very useful, but isn’t.
I mean, I don’t disagree with you that comment generation systems have limitations. But they are actually quite useful. The comments here in this example where you basically say “this addition adds function name” can be generated by an algorithm that uses names in it’s input.
Here is a snippet from your project that I saw, I meant most of these comments here can be generated automatically. I don’t know if you actually wrote them, though. This is just a project on your front GitHub page.
def make_popup(lines):
nonlocal popup
lines = lines[:height - 5] # Truncate if we don't have enough screen space
popup = curses.newwin(len(lines) + 2, width - 4, 2, 2)
popup.erase()
popup.border()
for i, line in enumerate(lines):
if not isinstance(line, tuple): line = (line,)
popup.addstr(i + 1, 1, line[0][:width - 6], *line[1:])
popup.refresh()
curses.curs_set(0)
nonautodeps = []
while True:
height, width = scr.getmaxyx() # Also used by make_popup()
if height != lastheight:
# Note that a resize event is sent through as a pseudo-key, so
# this will trigger immediately, without waiting for the next
# actual key.
lastheight, lastpage = height, None
scr.setscrreg(0, height - 1)
perpage = min(height - 8, len(upgrades))
scr.move(perpage + 2, 0)
scr.clrtobot()
print()
if auto: print("Plus %d auto-installed packages." % auto)
print("Select packages to upgrade, then Enter to apply.")
print("Press ? for help, or Q to quit without making any changes")
pagestart = pkg - pkg % perpage
if pagestart != lastpage:
lastpage = pagestart
# Update (only if the page has changed)
for i, d in enumerate(desc[pagestart : pagestart + perpage]):
scr.addstr(i + 2, 0, fmt % ((actions[pagestart + i],) + tuple(d.values())))
# Erase any spare space, including the mandatory blank at the end
for i in range(i + 1, perpage + 1):
# Is this the best way to clear a line??
scr.move(i + 2, 0)
scr.clrtoeol()
scr.setscrreg(2, perpage + 4)
scr.move((pkg % perpage) + 2, 1)
key = scr.getkey()
if popup:
# Restricted key handling when a popup is open
if key in "Aa" and nonautodeps:
for i, p in enumerate(upgrades):
if p in nonautodeps:
toggle(i, "A")
if key in "?QqIiAa":
popup = None
nonautodeps = []
scr.touchwin()
scr.refresh()
curses.curs_set(2)
continue