Uncategorized

Survey on Python comments – Python Help


In the post I replied to originally. Also @Rosuav was saying the same thing multiple times in this thread, verbatim. You just have to scroll up to see. Here →

you have defined a comment to be something not present in the code. If it’s not what you meant, please explain, then.

Also it is possible that both you and @Rosuav were making similar points and I am conflating both of your arguments into one, but it might not be the case.

Anyway, I didn’t claim that every comment generated by ChatGPT is needed. I said that in general all generated comments in that example are useful for understanding the code to someone who has never seen it. I completely agree that document “nonlocal” declaration is redundant and I would never write it. But I also specifically asked for a comment to be there from ChatGPT.
You can’t actually blame the generation system for producing the comments that you asked it to produce. Many of those comments are indeed redundant and can safely be removed, but some of them are actually stuff I would keep.
For example, I would keep this one

# Hide the cursor
    curses.curs_set(0)

this is useful and informative. This api call is poorly designed for readability and unless you know the api and have worked with it recently, you won’t be able to figure out what it does.

 # Display each line of the popup
    for i, line in enumerate(lines):
        if not isinstance(line, tuple):
            line = (line,)
        popup.addstr(i + 1, 1, line[0][:width - 6], *line[1:])

I would also keep this one, albeit this one is arguable, I am also willing to let it go. But this is in general a good summary for the following block of code which is not particularly clear what it does without knowing api in detail. The function addstr is not descriptive enough for me to infer that it actually for displaying the line and not for something like adding data to internal data sctructure like a list box.

and this

# List to store packages without automatic dependencies
nonautodeps = []

isn’t this an example of a perfectly good and useful comment generated by ChatGPT? I mean this is perfect. It tells my why this object exists and what it is used for. I don’t have to go parse the code with my eyes, track all usages of it and then figure it out. Well, if it’s actually correct. If it’s wrong, then it’s obviously bad.



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *