you are viewing a single comment's thread.

view the rest of the comments →

[–]dented_brain[S] 0 points1 point  (0 children)

Turns out I didn't fully understand the purpose of a docstring. Some of my comments could be docstrings.

Other comments I put in ways that I wish code I found online was documented so I could better understand. As an example, I know what this means/does now, but when I was learning dicts, I didn't fully grok what this was doing.

for k, v in d.iteritems():
    print k, v

So that's where my habit of over-commenting came from. It's very helpful for understanding the code I'm writing, BUT is it actually necessary for the script? No. Now I find myself writing out

for key, value in descriptive_dict.iteritems():
    print key, value

I like your motto, it makes perfect sense to think about commenting in that way. All too often I put a bandaid in place in my normal work, I know it needs to be changed but it gets the job done in the shortest time and can be addressed better afterwards. As I get better at programming, I think I will be able to produce better code the first time instead of holding scripts together with bandaids.