Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!nntp-feed.chiark.greenend.org.uk!ewrotcd!news.nosignal.org!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.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'correct.': 0.09; 'global,': 0.09; 'received:mail-lpp01m010-f46.google.com': 0.09; 'am,': 0.12; 'def': 0.13; 'lookup': 0.16; 'subject:() ': 0.16; 'subject:sum': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.18; 'subject:not': 0.19; 'cheers,': 0.20; 'cc:no real name:2**0': 0.21; "doesn't": 0.22; 'header:In-Reply-To:1': 0.22; 'feb': 0.22; 'statement': 0.23; 'here?': 0.23; '\xa0if': 0.23; 'cc:2**0': 0.26; 'missed': 0.28; 'message-id:@mail.gmail.com': 0.29; '24,': 0.29; 'cc:addr:python.org': 0.29; 'pm,': 0.29; 'subject:number': 0.30; 'chris': 0.30; 'received:209.85.215.46': 0.32; 'thu,': 0.32; 'there': 0.33; 'fri,': 0.34; '...': 0.35; 'something': 0.35; 'reference': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.38; 'somewhat': 0.38; 'could': 0.38; 'received:209.85.215': 0.39; 'received:209': 0.39; 'header:Received:6': 0.61; 'believe': 0.65; 'cause': 0.67; 'received:10.152': 0.84 Received-SPF: pass (google.com: domain of ian.g.kelly@gmail.com designates 10.152.110.234 as permitted sender) client-ip=10.152.110.234; Authentication-Results: mr.google.com; spf=pass (google.com: domain of ian.g.kelly@gmail.com designates 10.152.110.234 as permitted sender) smtp.mail=ian.g.kelly@gmail.com; dkim=pass header.i=ian.g.kelly@gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=dGIQs4rNrdRj7Tn0z2dQQvxx5zc9ZUFsEX+0mXdy/uI=; b=Lf5nGRni5Tdj/+aQa3kpUHfM8X1S/bYGkRq4BSgcGegEy8iLTmBjekiHu3FKmtIITh oncrvjin++PxV/0B71x4K/4X9iIAhqZAbAlJ4Ilp0pVuxX+i/MgliLxPjv9RkGajWqDt vk6juj3xLUgI9vXcGvo3wXGDzyOHHAyOq/Iwk= MIME-Version: 1.0 In-Reply-To: References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> <41177e2c-3cf7-4678-8594-5a81290eaa4d@ub4g2000pbc.googlegroups.com> From: Ian Kelly Date: Thu, 23 Feb 2012 15:00:07 -0700 Subject: Re: sum() requires number, not simply __add__ To: Chris Angelico Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org 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: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1330034439 news.xs4all.nl 6949 [2001:888:2000:d::a6]:36386 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:20758 On Thu, Feb 23, 2012 at 2:53 PM, Chris Angelico wrote: > On Fri, Feb 24, 2012 at 8:41 AM, Arnaud Delobelle wro= te: >> _sentinel =3D object() >> >> def sum(iterable, start=3D_sentinel): >> =A0 =A0if start is _sentinel: >> >> del _sentinel > > Somewhat off-topic: Doesn't the if statement there do a lookup for a > global, which would mean that 'del _sentinel' will cause it to fail? > Or have I missed something here? I believe you're correct. If you really want to delete the _sentinel reference though, you could do: def sum(iterable, start=3Dobject()): if start is sum.func_defaults[0]: ... Cheers, Ian