Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!bcyclone03.am1.xlned.com!bcyclone03.am1.xlned.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.035 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'programmer': 0.03; 'cc:addr:python-list': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'cc:addr:python.org': 0.22; 'choices': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; '13,': 0.31; 'assert': 0.31; 'could': 0.34; 'received:google.com': 0.35; 'nov': 0.38; 'even': 0.60; 'played': 0.84; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=f5u9rhfWTaWQZ3omfVOjmpYbPmwhivXsNqmLvcerw/o=; b=yRkNx4S7VnOugU38cYRYgpj7Efa3vLE30hALNxZZ6pfzPVu5trzOhO58rAEGXhCQXN t4V5dWUIjcjK1BNWfPaCEEXvfN2cx4SYjFA1vCi552m4vXwTYiJzfYuKnJFvZvjaNva0 3VJQ4jH4OwdTJgIFUwVYXoX9fqWkJ4Jzo37vrNR1HIlB6mmKnkqyR8UPyJBLxWu0yGlp dOrTWLLnBcwOQc9um32XZsU5SWTpks83SWpaL/gn6BhWYT/STBpt2F08U3whLYDIWylO 02CELhX/Gpz/d959GNhan2RnaujGR+8Szw2dbDQkOiAX519Q4AMm2pemJpQb2ReYgr1B 9ILg== MIME-Version: 1.0 X-Received: by 10.50.79.135 with SMTP id j7mr43487396igx.14.1415834873209; Wed, 12 Nov 2014 15:27:53 -0800 (PST) In-Reply-To: <878ujgovfn.fsf@elektro.pacujo.net> References: <96c138e4-ab95-4e5f-a0c8-e696b5a926bb@googlegroups.com> <87a93wqeq3.fsf@elektro.pacujo.net> <87y4rgozgd.fsf@elektro.pacujo.net> <0cdc67f4-d9d5-4a73-91fe-7558161246af@googlegroups.com> <28e159ff-3d64-4793-9082-05cf1553c7c2@googlegroups.com> <878ujgovfn.fsf@elektro.pacujo.net> Date: Thu, 13 Nov 2014 10:27:53 +1100 Subject: Re: I love assert From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 15 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1415834876 news.xs4all.nl 2942 [2001:888:2000:d::a6]:54557 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 3705 X-Received-Body-CRC: 263023834 Xref: csiph.com comp.lang.python:80661 On Thu, Nov 13, 2014 at 10:23 AM, Marko Rauhamaa wrote: > However, the programmer could have played this frustration out already > in his head and written: > > assert len(choices) > 0 > count = next_size / len(choices) assert choices count = next_size / len(choices) Or even just: count = next_size / len(choices) # choices won't be empty ChrisA