Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; ';-)': 0.03; 'jeff': 0.04; 'assign': 0.07; '__name__': 0.09; 'debugging.': 0.09; 'subject:method': 0.09; 'def': 0.12; '(lambda': 0.16; 'attribute,': 0.16; 'foo():': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'llama': 0.16; 'mapped': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'received:211.29': 0.16; 'received:211.29.132': 0.16; 'received:cskk.homeip.net': 0.16; 'received:homeip.net': 0.16; 'received:optusnet.com.au': 0.16; 'received:syd.optusnet.com.au': 0.16; 'simpson': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'header:User- Agent:1': 0.23; 'documented': 0.24; "i've": 0.25; 'pass': 0.26; 'subject:/': 0.26; 'defined': 0.27; 'header:In-Reply-To:1': 0.27; 'tim': 0.29; 'ride': 0.30; 'chase': 0.31; 'cases': 0.33; 'table': 0.34; 'subject:the': 0.34; 'received:com.au': 0.36; 'doing': 0.36; 'charset:us-ascii': 0.36; 'received:211': 0.38; 'to:addr:python- list': 0.38; 'subject:" ': 0.39; 'to:addr:python.org': 0.39; 'even': 0.60; 'content-disposition:inline': 0.62; 'name': 0.63; 'as:': 0.81; '"".': 0.84; "'foo'": 0.84; 'alone.': 0.84; 'batchelder': 0.84 Date: Mon, 18 Nov 2013 11:19:35 +1100 From: Cameron Simpson To: python-list@python.org Subject: Re: Obtaining "the" name of a function/method MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20131117134726.5fef18ca@bigbox.christie.dr> User-Agent: Mutt/1.5.21 (2010-09-15) References: <20131117134726.5fef18ca@bigbox.christie.dr> X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=bpB1Wiqi c=1 sm=1 tr=0 a=YuQlxtEQCowy2cfE5kc7TA==:117 a=YuQlxtEQCowy2cfE5kc7TA==:17 a=ZtCCktOnAAAA:8 a=PO7r1zJSAAAA:8 a=LcaDllckn3IA:10 a=3cVPL3iCLZkA:10 a=kj9zAlcOel0A:10 a=vrnE16BAAAAA:8 a=8AHkEIZyAAAA:8 a=dcuPJXOhDUUA:10 a=8uR6FKqcAAAA:8 a=0thQQEepAAAA:8 a=QeXVSe4XPbvEBS0e2E4A:9 a=CjuIK1q_8ugA:10 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: 1384733986 news.xs4all.nl 15969 [2001:888:2000:d::a6]:39830 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:59817 On 17Nov2013 13:47, Tim Chase wrote: > On 2013-11-17 11:34, Ned Batchelder wrote: > > Functions have a __name__ attribute, which is the name they were > > defined as: > > > > >>> def foo(): pass > > ... > > >>> foo.__name__ > > 'foo' > > >>> bar = foo > > >>> bar.__name__ > > 'foo' > > which they have even in less-than-useful situations: > > (lambda s: s.lower()).__name__ > > accurately returns that its name is "". So you get what you > pay for ;-) Also, it is documented that you may assign to __name__. I've started doing that in a few cases where I have a table of lambdas mapped by operation names; I've started labelling the lambdas to get better debugging. -- Cameron Simpson Ride with a llama and you never ride alone. - Jeff Earls, DoD #0530,