Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #9176
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!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.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'sys': 0.05; '>>>>': 0.09; 'kinda': 0.09; 'object?': 0.09; 'pgp': 0.09; 'subject:Function': 0.09; 'message-----': 0.12; 'am,': 0.13; 'received:209.85.214.174': 0.13; 'received:mail- iw0-f174.google.com': 0.13; 'wrote:': 0.15; '"""find': 0.16; ' -----begin': 0.16; 'except:': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'hash:': 0.16; 'subject:variable': 0.16; 'test():': 0.16; 'traceback.': 0.16; "hasn't": 0.16; 'mon,': 0.16; 'pm,': 0.16; '>>>': 0.16; 'def': 0.16; 'header:In-Reply-To:1': 0.22; 'worked': 0.24; 'traceback': 0.25; 'function': 0.26; "i'm": 0.27; 'received:209.85.214': 0.28; 'message-id:@mail.gmail.com': 0.28; 'import': 0.29; 'objects.': 0.30; 'print': 0.32; 'signed': 0.32; 'andrew': 0.32; "i've": 0.33; 'to:addr:python-list': 0.34; 'there': 0.34; 'someone': 0.34; '...': 0.34; 'try:': 0.35; 'johnson': 0.35; 'assuming': 0.37; 'but': 0.37; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'received:209': 0.40; '11,': 0.68; 'look,': 0.84; 'subject:local': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=LzJaKMnMFkCi8t8fAa8l6YMpYHeQlzkbbRsHVywPDws=; b=sBIqVl/da13YG/TNwnm4fJ9Qf0lFB6Otn/wTU9v4sFcs7IJIcW6INx+l/GwPmfHvQL NEcUfGEiPlhBGrju0JUhYtKrobsxz0Yzg12Uk22J9tszggy45W/yB96tYOzvIZClYytd ZkZgXSf0IJP0H7PbQXPpTErPUlsUMmMeozi9Q= |
| MIME-Version | 1.0 |
| In-Reply-To | <4E19E5A5.5020905@gmail.com> |
| References | <20110710174121.GB12935@johnsons-web.com> <4E19E5A5.5020905@gmail.com> |
| Date | Mon, 11 Jul 2011 04:11:14 +1000 |
| Subject | Re: Function docstring as a local variable |
| 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.12 |
| 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.844.1310321477.1164.python-list@python.org> (permalink) |
| Lines | 32 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1310321477 news.xs4all.nl 21790 [2001:888:2000:d::a6]:41657 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:9176 |
Show key headers only | View raw
On Mon, Jul 11, 2011 at 3:47 AM, Andrew Berg <bahamutzero8825@gmail.com> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: RIPEMD160
>
> On 2011.07.10 12:41 PM, Tim Johnson wrote:
>> It possible for a function to print it's own docstring?
>>>> def test():
> ... """Hi there."""
> ... print(test.__doc__)
That's assuming that it knows its own name, and that that name hasn't
been rebound. Is there a way for a function to find its own self?
>>> def findself():
"""Find myself. Ooh look, there I am!"""
import sys
try:
1/0
except:
traceback=sys.exc_info()[2]
# Now I'm not sure what to do with traceback.
# traceback.tb_frame.f_code.co_name is the function name ("findself").
# Is there a way to get the function object?
I'm kinda half-way there, but I've never worked with traceback
objects. Someone will know, I'm sure!
ChrisA
ChrisA
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Re: Function docstring as a local variable Chris Angelico <rosuav@gmail.com> - 2011-07-11 04:11 +1000
Re: Function docstring as a local variable Richard Thomas <chardster@gmail.com> - 2011-07-10 14:16 -0700
Re: Function docstring as a local variable python@bdurham.com - 2011-07-10 18:13 -0400
Re: Function docstring as a local variable Roy Smith <roy@panix.com> - 2011-07-10 18:41 -0400
Re: Function docstring as a local variable Tim Johnson <tim@johnsons-web.com> - 2011-07-10 14:50 -0800
Re: Function docstring as a local variable Tim Chase <python.list@tim.thechases.com> - 2011-07-10 18:14 -0500
csiph-web