Most gratuitous comments

sohcahtoa82 at gmail.com sohcahtoa82 at gmail.com
Thu Nov 20 18:59:31 EST 2014


On Thursday, November 20, 2014 3:16:33 PM UTC-8, Steven D'Aprano wrote:
> sohcahtoa82 at gmail.com wrote:
> 
> > On Thursday, November 20, 2014 1:33:16 PM UTC-8, c... at isbd.net wrote:
> >> s... at gmail.com wrote:
> >> > 
> >> > # increment x
> >> > x += 1
> >> 
> >> But it shouldn't say 'increment x', it should say 'add one to the line
> >> count' or some such.  Although changing the variable name to
> >> 'lineCount' would do almost as well.
> > 
> > This is the kind of pedantic crap I was referring to in another thread.
> > 
> > Of course I wouldn't call a variable 'x' unless it was representing an x
> > coordinate in 2D or 3D space.
> 
> 
> I think you may have missed the point of Chris' post. In context, the use
> of "x" as a variable might be meaningful, but "x" can also be an archetypal
> bad variable name. Chris' point is that choosing a meaningful name can be
> self-documenting and so reduces the need for comments.

My point was that I was making fun of CS professors that demand a comment on every line of code, regardless of how clear the line of code is.  The fact that I happened to use 'x' as a variable name was inconsequential, and I felt that Chris's criticism of using a single-letter variable name was pedantic because it missed the point entirely and picked on something else that wasn't an issue.

I was trying to illustrate the point that some professors would demand you write code like this...

# increment the line count
lineCount += 1

# Check if line count is over 10
if lineCount > 10
    # Tell the user there are too many lines
    print 'There are too many lines!

...which is obviously bad commenting style.  But I guess my original minimal example was too minimal.


> 
> (By the way, whatever tool you are using to post comments is badly breaking
> attributions. It is polite to give the person's full name when quoting
> them, when they provide one, if not give their full email address.
> Truncating their email address to a single letter before the "@" has no
> useful purpose and breaks attribution.)
> 
> 
> 
> -- 
> Steven

I use Google Groups which seems to be pretty unpopular on this list.  Does it break thread organization?  Or is it really just a politeness thing?



More information about the Python-list mailing list