Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python': 0.08; 'none.': 0.09; 'received:10.50': 0.09; 'think?': 0.09; 'am,': 0.12; 'def': 0.13; 'argument': 0.15; 'subject:was': 0.15; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'omitted.': 0.16; 'subject:() ': 0.16; 'subject:sum': 0.16; 'subject:syntax': 0.16; 'wrote:': 0.18; '>>>': 0.18; 'subject:not': 0.19; 'received:209.85.210.174': 0.21; 'received:mail- iy0-f174.google.com': 0.21; 'feb': 0.22; 'optional': 0.23; '\xa0if': 0.23; 'object,': 0.24; 'otherwise,': 0.25; 'skip:_ 20': 0.26; 'message-id:@mail.gmail.com': 0.29; '24,': 0.29; 'problem': 0.29; 'basically,': 0.30; 'subject:number': 0.30; 'syntax,': 0.30; 'chris': 0.30; 'that,': 0.32; 'list': 0.32; 'object': 0.33; 'fri,': 0.34; 'to:addr:python-list': 0.35; 'trouble': 0.35; 'received:google.com': 0.37; 'difference': 0.38; 'received:209.85': 0.38; 'could': 0.38; 'some': 0.38; 'received:209': 0.39; 'subject: (': 0.40; 'to:addr:python.org': 0.40; 'unique': 0.61; 'header:Received:6': 0.61; 'more': 0.61; 'here': 0.64; 'as:': 0.70; 'introduce': 0.82 Received-SPF: pass (google.com: domain of rosuav@gmail.com designates 10.50.87.201 as permitted sender) client-ip=10.50.87.201; Authentication-Results: mr.google.com; spf=pass (google.com: domain of rosuav@gmail.com designates 10.50.87.201 as permitted sender) smtp.mail=rosuav@gmail.com; dkim=pass header.i=rosuav@gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=TMi4rF8Edu1uJ5yae2fwtNV6bcG2BwPV+ne4hBaF/MA=; b=bdE6NeEiw0CuVqHK0b+b1mhO5L5AypLRmkEVNHnp7Har4omU0m6xAGLvGOUEx8FWOj VND92N004IHbEDVEMyfylGvmNHS9izVM358rN2xp2F643RVYILHt2G0FPzY+iqwNjRK5 WR/pu/xZ6XCmG85igqGjphSt5XxVtedVigE+8= MIME-Version: 1.0 Date: Fri, 24 Feb 2012 09:11:51 +1100 Subject: Optional arguments syntax (was Re: sum() requires number, not simply __add__) 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: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1330035113 news.xs4all.nl 6848 [2001:888:2000:d::a6]:45943 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:20761 On Fri, Feb 24, 2012 at 9:09 AM, Arnaud Delobelle wrote= : > On 23 February 2012 22:04, Chris Angelico wrote: >> On Fri, Feb 24, 2012 at 8:59 AM, Arnaud Delobelle wr= ote: >>> def sum(iterable, start=3D_sentinel, _sentinel=3D_sentinel): >> >> Is this a reason for Python to introduce a new syntax, such as: >> >> def foo(blah, optional=3Ddel): >> =A0 =A0if optional is del: print("No argument was provided") >> >> Basically, 'del' is treated like a unique non-providable object, only >> possible in an argument list and only if the argument was omitted. No >> more proliferation of individual sentinels... what do you think? > > The problem with these proposals is to avoid the leakage of 'del'. > Here you could do: > > def get_del(x=3Ddel): > =A0 =A0return x > > And then you're in trouble again. Yep; what I was thinking was that this would be a magic token that, if used in any expression other than "is del", would decay to some other object such as 0 or None. Otherwise, yeah, there's no difference between that and any other global sentinel. ChrisA