In the way that’s common in languages like Java where you’re making a property read-only, yes. But there’s a whole protocol in Python called descriptors where you can override the . on a field. The most common form of these is class methods annotated with the @property annotation, which makes it so the method can be accessed as if it were a property.
I helped a friend debug a script last week that was working inconsistently in really weird ways. I looked at the script and it was all event hooks littered with sleep calls. I told him he was basically fuzz testing his own script and then getting surprised when he found race conditions. Shit was wild. Also, sometimes getters in Python are a mistake.
You left out the part where, instead of telling him to knock it off as soon as they learned about it and disciplining him internally as a student, the school contacted law enforcement and allowed him to continue doing it so they could prosecute him harder make an example out of him. You’d think if he was as big of a threat as you’re implying, they would stop what he was doing ASAP. And if you’re going to be pedantic about leaving out details, maybe tell the whole thing. Maybe it’s not “honest” enough if we haven’t posted the full text of a documentary in a comment. That’s clearly your call.
I often use comments as ways to say, “I know this is cursed, but here’s why the obvious solution won’t work.” Like so:
/**
* The column on this table is badly named, but
* renaming it is going to require an audit of our
* db instances because we used to create them
* by hand and there are some inconsistencies
* that referential integrity breaks. This method
* just does some basic checks and translates the
* model’s property to be more understandable.
* See [#27267] for more info.
*/
Edit: to answer your question more directly, the “why not what” advice is more about the intent of whether to write a comment or not in the first place rather than rephrasing the existing “what” style comments. What code is doing should be clear based on names of variables and functions. Why it’s doing that may be unclear, which is why you would write a comment.
Thank god