Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #35591
| 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 | <rosuav@gmail.com> |
| 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; 'attribute': 0.05; '__name__': 0.07; 'function,': 0.07; 'python': 0.09; '(aka': 0.09; '(although': 0.09; 'itself,': 0.09; 'subject:while': 0.09; 'dec': 0.15; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'function).': 0.16; 'string': 0.17; 'wrote:': 0.17; 'thu,': 0.17; 'module': 0.19; 'script': 0.24; 'header:In-Reply-To:1': 0.25; 'looks': 0.26; '(which': 0.26; 'message-id:@mail.gmail.com': 0.27; 'received:209.85.212': 0.28; 'run': 0.28; 'function': 0.30; 'function.': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'pm,': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'itself': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'called': 0.39; 'skip:" 10': 0.40; 'header:Received:5': 0.40; 'your': 0.60; 'kind': 0.61; '(yes,': 0.84 |
| 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:content-transfer-encoding; bh=q32/UCncFTEknd9eMIsijd+whZZWQvu7Fkqfhxoy8r0=; b=Sp8WAhSSOk8lsVlmrXs3M5anvo5EnyZuRuC5ttra30OWDLBiiL8sYr3OOcRzbjnl2g xo7HfEKgEN+EewXEJKmZsgtAP4dBzYTitfqktXUB2hNn7bOzS9vB1ICKlJa0ZCnKc8Lq Sk4UyU0BwNuKF3RNtnFrFGvI9c5RgHlLXr3xLYcVDkbUnuxK/qwEmcnNv5Zp9RpQ0SN/ izePlr4vEwim/kfVCb08mNIXl33i4xYx7QidaGIAA1ouZPNstHlPP0GTecWTV7nuKTQZ sjtm23iqCy6qLbXs7SUX1dRD31CWohdZXtQnT1lMQxRosPfxfbYc7a2Xm+oo1vdBJzyT YFEg== |
| MIME-Version | 1.0 |
| In-Reply-To | <9ca1c0f1-fd79-4525-a571-64f1efb2eefa@googlegroups.com> |
| References | <c9548d77-ccc3-4b47-b84b-9a9f0c2852ce@googlegroups.com> <roy-F99DCA.22112825122012@news.panix.com> <9ca1c0f1-fd79-4525-a571-64f1efb2eefa@googlegroups.com> |
| Date | Thu, 27 Dec 2012 18:48:19 +1100 |
| Subject | Re: Finding the name of a function while defining it |
| From | Chris Angelico <rosuav@gmail.com> |
| To | python-list@python.org |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | quoted-printable |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1329.1356594507.29569.python-list@python.org> (permalink) |
| Lines | 13 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1356594507 news.xs4all.nl 6868 [2001:888:2000:d::a6]:50582 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:35591 |
Show key headers only | View raw
On Thu, Dec 27, 2012 at 6:26 PM, Abhas Bhattacharya <abhasbhattacharya2@gmail.com> wrote: > During run-time, I can always use: function_name.__name__ (although that's kind of lame because it returns "function_name"). But if the function itself contains print(__name__) and I call the function, it returns __main__ (yes, __main__ itself, not the string "__main__") (which is the calling function). That's because __name__ looks for that attribute on the module (aka "global variable"), not the function. When you run your Python script as an application, the module is called __main__. ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Finding the name of a function while defining it Abhas Bhattacharya <abhasbhattacharya2@gmail.com> - 2012-12-25 18:00 -0800
Re: Finding the name of a function while defining it Roy Smith <roy@panix.com> - 2012-12-25 22:11 -0500
Re: Finding the name of a function while defining it Abhas Bhattacharya <abhasbhattacharya2@gmail.com> - 2012-12-26 23:26 -0800
Re: Finding the name of a function while defining it Chris Angelico <rosuav@gmail.com> - 2012-12-27 18:48 +1100
Re: Finding the name of a function while defining it Abhas Bhattacharya <abhasbhattacharya2@gmail.com> - 2012-12-26 23:52 -0800
Re: Finding the name of a function while defining it Abhas Bhattacharya <abhasbhattacharya2@gmail.com> - 2012-12-26 23:52 -0800
Re: Finding the name of a function while defining it Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-12-27 12:59 +0000
Re: Finding the name of a function while defining it Tim Roberts <timr@probo.com> - 2012-12-26 20:52 -0800
Re: Finding the name of a function while defining it Chris Angelico <rosuav@gmail.com> - 2012-12-27 16:44 +1100
Re: Finding the name of a function while defining it Abhas Bhattacharya <abhasbhattacharya2@gmail.com> - 2012-12-26 23:46 -0800
Re: Finding the name of a function while defining it Chris Angelico <rosuav@gmail.com> - 2012-12-27 18:52 +1100
Re: Finding the name of a function while defining it Abhas Bhattacharya <abhasbhattacharya2@gmail.com> - 2012-12-26 23:55 -0800
Re: Finding the name of a function while defining it Abhas Bhattacharya <abhasbhattacharya2@gmail.com> - 2012-12-26 23:55 -0800
Re: Finding the name of a function while defining it Abhas Bhattacharya <abhasbhattacharya2@gmail.com> - 2012-12-26 23:46 -0800
Re: Finding the name of a function while defining it Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-12-27 10:58 +0000
Re: Finding the name of a function while defining it Tim Chase <python.list@tim.thechases.com> - 2012-12-27 07:32 -0600
Re: Finding the name of a function while defining it Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-12-27 13:34 +0000
Re: Finding the name of a function while defining it Roy Smith <roy@panix.com> - 2012-12-27 10:09 -0500
Re: Finding the name of a function while defining it Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-12-28 01:07 +0000
Re: Finding the name of a function while defining it Abhas Bhattacharya <abhasbhattacharya2@gmail.com> - 2012-12-26 23:45 -0800
Re: Finding the name of a function while defining it Mitya Sirenef <msirenef@lightbird.net> - 2012-12-27 03:03 -0500
Re: Finding the name of a function while defining it Abhas Bhattacharya <abhasbhattacharya2@gmail.com> - 2012-12-27 00:26 -0800
Re: Finding the name of a function while defining it Mitya Sirenef <msirenef@lightbird.net> - 2012-12-27 04:07 -0500
Re: Finding the name of a function while defining it Abhas Bhattacharya <abhasbhattacharya2@gmail.com> - 2012-12-27 00:26 -0800
Re: Finding the name of a function while defining it Chris Rebert <clp2@rebertia.com> - 2012-12-27 00:58 -0800
Re: Finding the name of a function while defining it Tim Roberts <timr@probo.com> - 2012-12-28 21:01 -0800
Re: Finding the name of a function while defining it Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2012-12-29 12:18 +0200
Re: Finding the name of a function while defining it Chris Rebert <clp2@rebertia.com> - 2012-12-27 00:26 -0800
Re: Finding the name of a function while defining it Abhas Bhattacharya <abhasbhattacharya2@gmail.com> - 2012-12-27 00:42 -0800
Re: Finding the name of a function while defining it Abhas Bhattacharya <abhasbhattacharya2@gmail.com> - 2012-12-27 00:42 -0800
Re: Finding the name of a function while defining it Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-12-27 13:31 +0000
Re: Finding the name of a function while defining it alex23 <wuwei23@gmail.com> - 2012-12-27 17:25 -0800
csiph-web