Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3.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.021 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'syntax': 0.04; 'none:': 0.07; 'translate': 0.10; 'def': 0.12; '-tkc': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'object()': 0.16; 'wrote:': 0.18; 'compiled': 0.26; 'pass': 0.26; 'header:In-Reply-To:1': 0.27; 'getting': 0.31; "d'aprano": 0.31; 'skip:! 10': 0.31; 'steven': 0.31; 'skip:_ 10': 0.34; 'something': 0.35; 'there': 0.35; 'charset:us-ascii': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'skip:x 10': 0.40; 'expression': 0.60; 'times': 0.62; 'such': 0.63; 'received:50.22': 0.84; 'subject:Value': 0.84 Date: Thu, 20 Jun 2013 20:26:34 -0500 From: Tim Chase To: python-list@python.org Subject: Re: Default Value In-Reply-To: <51c3a799$0$29999$c3e8da3$5496439d@news.astraweb.com> References: <7e6361d5-6619-4aaa-adda-8b5f01bde57f@googlegroups.com> <447dd1c6-1bb2-4276-a109-78d7a067b442@d8g2000pbe.googlegroups.com> <2e92b4c7-31be-40d2-a906-ab19f3630dfa@googlegroups.com> <09cfa648-ab87-4261-b8f0-bf493de00553@4g2000pbf.googlegroups.com> <51c3a799$0$29999$c3e8da3$5496439d@news.astraweb.com> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - boston.accountservergroup.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tim.thechases.com 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: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1371777895 news.xs4all.nl 15924 [2001:888:2000:d::a6]:58311 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:48837 On 2013-06-21 01:08, Steven D'Aprano wrote: > Here's my syntax plucked out of thin air: > > def func(arg, x=expression, !y=expression): > ... > > where y=expression is late-bound, and the above is compiled to: > > def func(arg, x=expression, y=None): > if y is None: > y = expression > ... I think it would have to translate to something like _temp_semaphore = object() def func(arg, x=expression, y=_temp_semaphore): if y is _temp_semaphore: y = expression ... because there are times you want to be able to pass None as a legit value in such a case (speaking from the trenches after getting stung by exactly that case on multiple occasions). -tkc