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


Groups > comp.lang.python > #6476

Re: The worth of comments

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'int': 0.05; 'stuff.': 0.05; 'char': 0.07; 'compiler': 0.07; 'type,': 0.07; 'python': 0.08; 'down,': 0.09; 'extern': 0.09; 'function:': 0.09; 'subclass': 0.09; 'variants': 0.09; 'pm,': 0.10; 'def': 0.12; 'c++': 0.12; 'wrote:': 0.14; 'defined': 0.14; '(eg': 0.16; '*list*': 0.16; '11:36': 0.16; 'angelico': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'roy': 0.16; 'termination': 0.16; '\xa0this': 0.16; 'meant': 0.18; 'header:In-Reply-To:1': 0.21; 'trying': 0.23; 'null': 0.23; 'received:209.85.210.174': 0.23; 'received:mail- iy0-f174.google.com': 0.23; 'code': 0.24; 'testing': 0.27; 'message-id:@mail.gmail.com': 0.28; '(the': 0.28; 'sat,': 0.29; 'variables': 0.29; 'class': 0.29; 'code,': 0.29; 'actually.': 0.30; 'break;': 0.30; 'list).': 0.30; 'sort': 0.31; 'to:addr :python-list': 0.33; 'break': 0.33; 'things': 0.33; 'chris': 0.34; 'file': 0.34; 'compilation': 0.35; 'couple': 0.35; 'quite': 0.36; 'received:google.com': 0.37; 'useful': 0.37; 'received:209.85': 0.37; 'ways': 0.37; 'case': 0.37; 'another': 0.37; 'put': 0.37; 'two': 0.37; 'but': 0.38; 'subject:: ': 0.38; "i'd": 0.39; 'received:209': 0.39; 'to:addr:python.org': 0.39; 'everyone': 0.40; "couldn't": 0.40; 'your': 0.60; 'further': 0.65; 'designed': 0.65; 'dedicated': 0.65; 'subject:The': 0.69; 'unnecessary': 0.73; 'killing': 0.91; 'cause,': 0.93; 'programs:': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=XfCf9cobjp73RR/kIyY334L4TbAYo9kao5zGtkhZJtk=; b=rD3VoJPTM90AoDyP1GBJ/62BzxjM97a1Wp8LbFJMH2uQOm92kHYJ7JjJ833Y8toip0 Y6ahYXHZih4brNe+XtaZ08hdmUESbqMKWn1yQb2v3EE7xNlfm5aEE+bSQgqUUkwJOQQa eDTt413O1TpsGChz3FVAptiCbcS6GrZ03W9ew=
DomainKey-Signature a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=O8+H2CKIgGXsOIA61yQVRGGRVwtTqR6E5cWQURpdwMtW7/2slbXOcETzQBG01bPxtW 18LJ0hekVwY6VtaZqEx/THzXsKZhiFTXBL+So0XpqCbOZqkXI9WUBdRxe+P3ibCNLcVe t6lAhn+KAtfmfbNRcWMblpD9g3Ffeq9RZaNos=
MIME-Version 1.0
In-Reply-To <roy-84AF4C.09364328052011@news.panix.com>
References <mailman.8533.1306409304.9058.python-list@python.org> <mailman.2126.1306435826.9059.python-list@python.org> <87sjs0apgh.fsf@benfinney.id.au> <iroadr$3gj$1@reader1.panix.com> <4ddfd9bf$0$49183$e4fe514c@news.xs4all.nl> <irooea$kio$2@reader1.panix.com> <roy-84AF4C.09364328052011@news.panix.com>
Date Sun, 29 May 2011 00:02:57 +1000
Subject Re: The worth of comments
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2195.1306591380.9059.python-list@python.org> (permalink)
Lines 27
NNTP-Posting-Host 82.94.164.166
X-Trace 1306591380 news.xs4all.nl 49181 [::ffff:82.94.164.166]:47071
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:6476

Show key headers only | View raw


On Sat, May 28, 2011 at 11:36 PM, Roy Smith <roy@panix.com> wrote:
> def foo():
>   "Raise IndexError.  This is useful as a testing fixture."
>   l = [1, 2, 3]
>   return l[3]

A quite useful thing, on occasion. I have a couple of variants of
this, actually. In one of my C++ programs:

extern char *death1; extern int death2; //Globals for killing things with

// further down, inside a function:
case "death1": *death1=42; break; //Die by dereferencing NULL
case "death2": return 42/death2; //Die by dividing by zero

They were designed to verify the parent-process code that was meant to
catch process termination and identify the cause, so I wanted two
quite different ways of blowing up the program. (The variables were
extern and defined in another file to ensure that the compiler
couldn't outsmart me with a compilation error.)

In the Python code, that would be unnecessary with the *list* type,
but it might be of value with your own class (eg subclass of list).
Although, I'd put that sort of thing into a dedicated unit testing
section, where everyone _knows_ that you're trying to break stuff.

Chris Angelico

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


Thread

The worth of comments Richard Parker <r.richardparker@comcast.net> - 2011-05-26 11:50 -0700
  Re: The worth of comments Ben Finney <ben+python@benfinney.id.au> - 2011-05-27 11:42 +1000
    Re: The worth of comments Grant Edwards <invalid@invalid.invalid> - 2011-05-27 13:54 +0000
      Re: The worth of comments Irmen de Jong <irmen@-NOSPAM-xs4all.nl> - 2011-05-27 19:05 +0200
        Re: The worth of comments Grant Edwards <invalid@invalid.invalid> - 2011-05-27 17:53 +0000
          Re: The worth of comments Irmen de Jong <irmen.NOSPAM@xs4all.nl> - 2011-05-28 15:09 +0200
            Re: The worth of comments python@bdurham.com - 2011-05-28 09:34 -0400
          Re: The worth of comments Roy Smith <roy@panix.com> - 2011-05-28 09:36 -0400
            Re: The worth of comments Chris Angelico <rosuav@gmail.com> - 2011-05-29 00:02 +1000
            Re: The worth of comments Irmen de Jong <irmen.NOSPAM@xs4all.nl> - 2011-05-28 16:05 +0200
              Re: The worth of comments Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-05-29 12:47 +1200
                Re: The worth of comments Ben Finney <ben+python@benfinney.id.au> - 2011-05-29 11:41 +1000
                Re: The worth of comments Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-05-29 23:05 +1200
                Re: The worth of comments Grant Edwards <invalid@invalid.invalid> - 2011-05-29 14:43 +0000
                Re: The worth of comments Roy Smith <roy@panix.com> - 2011-05-29 11:39 -0400
                Re: The worth of comments Irmen de Jong <irmen.NOSPAM@xs4all.nl> - 2011-05-29 03:49 +0200
                Re: The worth of comments Alister Ware <alister.ware@ntlworld.com> - 2011-05-29 17:26 +0000
            Re: The worth of comments Neil Cerutti <neilc@norwich.edu> - 2011-05-31 14:47 +0000
  Re: The worth of comments Roy Smith <roy@panix.com> - 2011-05-26 22:08 -0400
    Re: The worth of comments Chris Angelico <rosuav@gmail.com> - 2011-05-27 15:13 +1000
      Re: The worth of comments Roy Smith <roy@panix.com> - 2011-05-27 09:25 -0400
    Re: The worth of comments Tim Roberts <timr@probo.com> - 2011-05-27 00:02 -0700
      Re: The worth of comments "D'Arcy J.M. Cain" <darcy@druid.net> - 2011-05-27 09:29 -0400
    RE: The worth of comments "Prasad, Ramit" <ramit.prasad@jpmchase.com> - 2011-05-27 14:17 -0400

csiph-web