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: 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: References: <87sjs0apgh.fsf@benfinney.id.au> <4ddfd9bf$0$49183$e4fe514c@news.xs4all.nl> Date: Sun, 29 May 2011 00:02:57 +1000 Subject: Re: The worth of comments From: Chris Angelico 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 On Sat, May 28, 2011 at 11:36 PM, Roy Smith wrote: > def foo(): > =A0 "Raise IndexError. =A0This is useful as a testing fixture." > =A0 l =3D [1, 2, 3] > =A0 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=3D42; 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