Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #81907

Re: Most gratuitous comments

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!217.188.199.168.MISMATCH!takemy.news.telefonica.de!telefonica.de!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <prvs=4081e7d36=jeanmichel@sequans.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.043
X-Spam-Evidence '*H*': 0.91; '*S*': 0.00; 'practice,': 0.07; 'assuming': 0.09; 'integers': 0.09; 'lines.': 0.09; 'properly.': 0.09; 'statements': 0.09; 'style.': 0.09; 'todo:': 0.09; 'cc:addr :python-list': 0.11; 'block.': 0.16; 'illustrate': 0.16; 'increment': 0.16; 'obviously': 0.18; 'bit': 0.19; 'module': 0.19; 'trying': 0.19; 'slightly': 0.19; 'value.': 0.19; 'example': 0.22; 'import': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'cheers,': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'logging': 0.26; 'asking': 0.27; 'values': 0.27; 'header:In-Reply- To:1': 0.27; 'point': 0.28; 'skip:( 20': 0.30; 'code': 0.31; 'comments': 0.31; 'easier': 0.31; 'lines': 0.31; '-----': 0.33; 'guess': 0.33; 'minimal': 0.33; 'comment': 0.34; 'trouble': 0.34; 'problem': 0.35; 'something': 0.35; 'but': 0.35; 'add': 0.35; 'there': 0.35; 'yield': 0.36; 'too': 0.37; 'thank': 0.38; 'little': 0.38; 'bad': 0.39; 'itself': 0.39; 'tell': 0.60; 'course': 0.61; 'you.': 0.62; 'back': 0.62; 'email addr:gmail.com': 0.63; 'information': 0.63; 'real': 0.63; 'received:194': 0.64; 'to:addr:gmail.com': 0.65; 'life': 0.66; 'notice:': 0.67; 'line,': 0.68; 'person,': 0.68; 'privileged.': 0.69; 'disclose': 0.74; '10:': 0.84; 'commenting': 0.84; 'this...': 0.84; 'demand': 0.91; 'habit': 0.91; 'medium.': 0.91
X-IronPort-AV E=Sophos;i="5.07,515,1413237600"; d="scan'208";a="3687216"
Date Thu, 4 Dec 2014 14:47:39 +0100 (CET)
From Jean-Michel Pichavant <jeanmichel@sequans.com>
To sohcahtoa82@gmail.com
In-Reply-To <6ab51e97-19c5-4008-a755-c55eb71469ba@googlegroups.com>
Subject Re: Most gratuitous comments
MIME-Version 1.0
X-Mailer Zimbra 7.2.7_GA_2942 (ZimbraWebClient - GC37 (Linux)/7.2.7_GA_2942)
Content-Type text/plain; charset="utf-8"
Content-Transfer-Encoding base64
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.16559.1417700930.18130.python-list@python.org> (permalink)
Lines 33
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1417700930 news.xs4all.nl 2957 [2001:888:2000:d::a6]:40649
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:81907

Show key headers only | View raw


----- Original Message -----
> From: sohcahtoa82@gmail.com
> 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.
> 

The problem is not that every line is commented, the problem is that comments do not add any value. There's always something to tell in real life situations:

# assuming all lines look like 'v=1234\n', generate all integers provided by the user
values = (int(line.replace('v=', '')) for line in lines)

# See SPE-xxx: 10 line max do not change it
if len(lines) > 10:
  # TODO: use the logging module
  print 'There are too many lines!


In practice, this yield to a comment every 2 or 3 lines. Of course this much depend on the code itself and may vary slightly from code block to code block. Note that I am not sanctioning the use of comment on import statements :D

To go back to your point, some professors may be right when asking a comment every line, because it will be easier then for someone to back off a little bit and comment slightly less. While students with the habit of writing no comment will have much trouble commenting properly.



Cheers,

JM









-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Most gratuitous comments Jean-Michel Pichavant <jeanmichel@sequans.com> - 2014-12-04 14:47 +0100

csiph-web