Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newspeer1.nac.net!newsfeed.xs4all.nl!newsfeed4a.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'assign': 0.07; 'parser': 0.07; '__name__': 0.09; 'arguments': 0.09; 'namespace': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'def': 0.12; 'jan': 0.12; 'bind': 0.16; 'lambda': 0.16; 'namespace.': 0.16; 'play.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'subject:def': 0.16; 'thereby': 0.16; 'so.': 0.16; 'wrote:': 0.18; 'issue.': 0.22; 'header:User-Agent:1': 0.23; "i've": 0.25; 'header:X -Complaints-To:1': 0.27; 'van': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; '(which': 0.31; 'anonymous': 0.31; 'correctly.': 0.31; 'becomes': 0.33; "can't": 0.35; 'but': 0.35; 'should': 0.36; 'easily': 0.37; 'filled': 0.38; 'to:addr :python-list': 0.38; 'does': 0.39; 'heard': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'name': 0.63; 'more': 0.64; 'received:fios.verizon.net': 0.84; 'subject:Alternative': 0.84; 'albert': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Alternative to multi-line lambdas: Assign-anywhere def statements Date: Wed, 11 Feb 2015 21:06:28 -0500 References: <54C3EAD1.2010501@stoneleaf.us> <54db5356$0$3915$e4fe514c@dreader34.news.xs4all.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-98-114-97-173.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 In-Reply-To: <54db5356$0$3915$e4fe514c@dreader34.news.xs4all.nl> 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: 34 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1423706801 news.xs4all.nl 2875 [2001:888:2000:d::a6]:48066 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:85559 On 2/11/2015 8:04 AM, Albert van der Horst wrote: > It is not until we assign the object to a name (which becomes thereby a function) > that the __name__ thingy comes into play, like so. But __name__ would not come into play. > f = x->x**2 This would mean to create an anonymous function object and then bind 'f' to that object in the current local namespace. It would be the same as the discouraged f = lambda x: x**2 > I've heard arguments that with -> the __name__ is not filled in correctly. Because local namespace name binding does not and should not mutate the object the name is bound to. > I can't see why the parser would understand more easily > > def f(x): > return x**2 > than > > f = x-> > return x**2 The parser parses both equally well. That is not the issue. -- Terry Jan Reedy