Re:Show HN: My Single-File Python Script I Used to Replace S...
by eigenvalue on Thursday September 21, 2023 @04:12PM
(#37603600)
I find comments annoying to read and write and distracting. I’d rather fit more code on the screen at once and instead focus on making the variable names and function names really descriptive and clear so you immediately grasp what it’s doing from context alone. Nowadays, if you really need comments to tell you what code is doing, you can just throw it into ChatGPT and get it that way.
[ Parent
| on HN ]
Re:Show HN: My Single-File Python Script I Used to Replace S...
by fastasucan on Thursday September 21, 2023 @05:07PM
(#37604349)
I really like the tool you made, and appreciate helping your company save money as well! I don't think it matter that this isn't a perfect fit for everyone else (as you said, this was something you made to solve your problem) - but boy do I disagree with the "variable and function names really descriptive and clear so you immediate grasp what its doing from context alone". What is a descriptive function or variable name is extremely dependent on how familiar you are with the context the program functions in. Using `execute_network_commands_func`from above - this descriptive name say nothing about what network commands that are executed. With docstrings it would be so easy to detail input and output of this function.
Re:Show HN: My Single-File Python Script I Used to Replace S...
by msm_ on Thursday September 21, 2023 @09:37PM
(#37606846)
I disagree with comments being distracting. You can overdo them, but one good comment - like "baz = 1 # the default is 1 instead of 0, because most real-world production servers foobars 1s into 7s" can save days of frustration.
In general, comments often add a very vaulable context to your code in a way that readaable function/variable names can't.