Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'function:': 0.09; 'here?': 0.09; 'lambda:': 0.09; 'subject:while': 0.09; 'def': 0.10; 'dec': 0.15; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'world!")': 0.16; 'wrote:': 0.17; 'thu,': 0.17; 'import': 0.21; 'idea': 0.24; 'header:In-Reply-To:1': 0.25; 'message- id:@mail.gmail.com': 0.27; 'received:209.85.212': 0.28; 'returned': 0.30; 'function': 0.30; 'up.': 0.31; 'could': 0.32; 'print': 0.32; 'anywhere': 0.33; 'goes': 0.33; 'to:addr:python- list': 0.33; 'another': 0.33; 'received:google.com': 0.34; 'text': 0.34; 'pm,': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'called': 0.39; 'header:Received:5': 0.40; 'your': 0.60 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=aN0p8dpz4VOhZZOpHlybn73Wa45cJtUwdCWynl/f3IM=; b=VQ4NxBCfa7AxyukVj6LqP95yD4eY0Wfwsql+emwSwWqgIjTXJotb4c6GcsWmLwzDiO hHDgGdXRGU5tFwJskKuQmHfVn/RlGSL1JUuJ6m6uj20O52lEgXe0ksQBrBOk20w7Mzuf MWlxUi4yx5gKqBz4tMM6Bjp42e2aaHFEDOVtECcnrRECSI200wQvCptHa/KF8A+MIJV+ Yua7DGGU+4iXotJM+/a+XT8wfpyoxH31VrxFKI7P9AZ1k+Ddi6FKH8QHtJo8oLXWTmji Brszeoayh9BiPvfOIpdW4jkNDTjKo6TsKivMluQY+hNEQCPAsLC0kl9osWEckbPj89e3 nKiA== MIME-Version: 1.0 In-Reply-To: <442ad592-1435-4be2-820d-970f7c8b86d0@googlegroups.com> References: <0kknd8tbg7knqa1ng6igbj8u82mqb720oi@4ax.com> <442ad592-1435-4be2-820d-970f7c8b86d0@googlegroups.com> Date: Thu, 27 Dec 2012 18:52:45 +1100 Subject: Re: Finding the name of a function while defining it From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1356594775 news.xs4all.nl 6899 [2001:888:2000:d::a6]:55375 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:35595 On Thu, Dec 27, 2012 at 6:46 PM, Abhas Bhattacharya wrote: > [ a whole lot of double-spaced quoted text - please trim it ] > If i call one() and two() respectively, i would like to see "one" and "two". That completely goes against your idea of knowing at compile-time, because the name "two" isn't anywhere around at that time. There's no way to know what name was used to look something up. It might not even have a name - the called function could well have been returned from another function: # foo.py def indirection(): return lambda: print # bar.py import foo foo.indirection()()("Hello, world!") What are the names of all the functions called here? ChrisA