Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'attribute': 0.05; 'lookup': 0.09; 'python:': 0.09; 'subject:while': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.10; 'def': 0.10; 'function?': 0.16; 'wrote:': 0.17; 'define': 0.20; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'prints': 0.29; 'class': 0.29; 'thursday,': 0.30; 'function': 0.30; 'december': 0.32; 'could': 0.32; 'defining': 0.33; 'received:google.com': 0.34; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'explain': 0.36; 'skip:p 20': 0.36; 'does': 0.37; 'received:209': 0.37; 'subject:: ': 0.38 Newsgroups: comp.lang.python Date: Thu, 27 Dec 2012 00:26:57 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=117.194.202.165; posting-account=4mdDiQoAAAB1VBViHzAN7cTcuXiGgMWL References: <0kknd8tbg7knqa1ng6igbj8u82mqb720oi@4ax.com> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 117.194.202.165 MIME-Version: 1.0 Subject: Re: Finding the name of a function while defining it From: Abhas Bhattacharya To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Cc: python-list@python.org 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: , Message-ID: Lines: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1356596827 news.xs4all.nl 6987 [2001:888:2000:d::a6]:52605 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:35600 On Thursday, 27 December 2012 13:33:34 UTC+5:30, Mitya Sirenef wrote: > > How about defining a function that prints value and then calls a function? > > > > def call(func_name): > > print(mydict[func_name]) > > globals()[func_name]() > > > > > > You could also define a custom class that does the same thing on attribute > > lookup and do something like Call.func_name() . > > > > -m > > > > -- > > Lark's Tongue Guide to Python: http://lightbird.net/larks/ Can you explain me what this means? globals()[func_name]()