Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #9195 > unrolled thread
| Started by | Carl Banks <pavlovevidence@gmail.com> |
|---|---|
| First post | 2011-07-10 15:59 -0700 |
| Last post | 2011-07-10 20:26 -0400 |
| Articles | 9 — 6 participants |
Back to article view | Back to comp.lang.python
Re: Function docstring as a local variable Carl Banks <pavlovevidence@gmail.com> - 2011-07-10 15:59 -0700
Re: Function docstring as a local variable Corey Richardson <kb1pkl@aim.com> - 2011-07-10 19:06 -0400
Re: Function docstring as a local variable alex23 <wuwei23@gmail.com> - 2011-07-10 21:14 -0700
Re: Function docstring as a local variable Andrew Berg <bahamutzero8825@gmail.com> - 2011-07-10 18:27 -0500
Re: Function docstring as a local variable Tim Johnson <tim@johnsons-web.com> - 2011-07-10 16:00 -0800
Re: Function docstring as a local variable Chris Rebert <clp2@rebertia.com> - 2011-07-10 17:09 -0700
Re: Function docstring as a local variable Chris Rebert <clp2@rebertia.com> - 2011-07-10 17:16 -0700
Re: Function docstring as a local variable Tim Johnson <tim@johnsons-web.com> - 2011-07-10 16:21 -0800
Re: Function docstring as a local variable Corey Richardson <kb1pkl@aim.com> - 2011-07-10 20:26 -0400
| From | Carl Banks <pavlovevidence@gmail.com> |
|---|---|
| Date | 2011-07-10 15:59 -0700 |
| Subject | Re: Function docstring as a local variable |
| Message-ID | <e44a7596-d01f-484b-9802-1e97fbbcf30f@glegroupsg2000goo.googlegroups.com> |
On Sunday, July 10, 2011 3:50:18 PM UTC-7, Tim Johnson wrote: > Here's a related question: > I can get the docstring for an imported module: > >>> import tmpl as foo > >>> print(foo.__doc__) > Python templating features > > Author - tim at akwebsoft dot com > > ## Is it possible to get the module docstring > ## from the module itself? print __doc__ Carl Banks
[toc] | [next] | [standalone]
| From | Corey Richardson <kb1pkl@aim.com> |
|---|---|
| Date | 2011-07-10 19:06 -0400 |
| Message-ID | <mailman.859.1310339300.1164.python-list@python.org> |
| In reply to | #9195 |
[Multipart message — attachments visible in raw view] — view raw
Excerpts from Carl Banks's message of Sun Jul 10 18:59:02 -0400 2011:
> print __doc__
>
Python 2.7.1 (r271:86832, Jul 8 2011, 22:48:46)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> def foo():
... "Docstring"
... print __doc__
...
>>> foo()
None
>>>
What does yours do?
--
Corey Richardson
"Those who deny freedom to others, deserve it not for themselves"
-- Abraham Lincoln
[toc] | [prev] | [next] | [standalone]
| From | alex23 <wuwei23@gmail.com> |
|---|---|
| Date | 2011-07-10 21:14 -0700 |
| Message-ID | <44de56f6-8ded-488f-a2bb-5b0f19582ef5@e20g2000prf.googlegroups.com> |
| In reply to | #9197 |
On Jul 11, 9:06 am, Corey Richardson <kb1...@aim.com> wrote:
> Excerpts from Carl Banks's message of Sun Jul 10 18:59:02 -0400 2011:
>
> > print __doc__
>
> Python 2.7.1 (r271:86832, Jul 8 2011, 22:48:46)
> [GCC 4.4.5] on linux2
> Type "help", "copyright", "credits" or "license" for more information.>>> def foo():
>
> ... "Docstring"
> ... print __doc__
> ...
>
> >>> foo()
> None
>
> What does yours do?
Is foo() declared in a module with a docstring? Because that's what
Carl was talking about.
test_module.py:
'''module docstring'''
def foo():
print __doc__
Works for me.
[toc] | [prev] | [next] | [standalone]
| From | Andrew Berg <bahamutzero8825@gmail.com> |
|---|---|
| Date | 2011-07-10 18:27 -0500 |
| Message-ID | <mailman.863.1310340495.1164.python-list@python.org> |
| In reply to | #9195 |
-----BEGIN PGP SIGNED MESSAGE----- Hash: RIPEMD160 On 2011.07.10 06:06 PM, Corey Richardson wrote: > Python 2.7.1 (r271:86832, Jul 8 2011, 22:48:46) [GCC 4.4.5] on > linux2 Type "help", "copyright", "credits" or "license" for more > information. >>>> def foo(): > ... "Docstring" ... print __doc__ ... >>>> foo() > None I get the same result with Python 3.2. - -- CPython 3.2 | Windows NT 6.1.7601.17592 | Thunderbird 5.0 PGP/GPG Public Key ID: 0xF88E034060A78FCB -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBAwAGBQJOGjV5AAoJEPiOA0Bgp4/LF2YH/jaEjS6sFuwekVG0cKyjnx/z 8j28OHB9mklXg6oEMSsypU5dVPst2a6fmEHm+sXPYgQHZ9tk0oun+xxmdldNyV8h knfFVgMC5ww1Q7gLkPWzY8me3k4YcokYGhsuwXEGBvPby4M4ZC5uyetKTzVWp+uH sO11DPBaaXzGj7E7wu+HbfWsvPxw9h9jfJ7ihjhHNSUiL3MkGEqlxK8Pw2o3cw1e sCY7XWm1x8qClJLrwwxnB7pfuOfNJ6aS3xLd8FFs4hRp1J9W+z4on91XZooa5kT+ UEfkrzppOjw1UNA1etxIGmJQ+/qrKSGg5Nmc4jHXNfwIZCECHuWxEqaL5e0WdHU= =5gdS -----END PGP SIGNATURE-----
[toc] | [prev] | [next] | [standalone]
| From | Tim Johnson <tim@johnsons-web.com> |
|---|---|
| Date | 2011-07-10 16:00 -0800 |
| Message-ID | <mailman.865.1310342448.1164.python-list@python.org> |
| In reply to | #9195 |
* Carl Banks <pavlovevidence@gmail.com> [110710 15:18]: > On Sunday, July 10, 2011 3:50:18 PM UTC-7, Tim Johnson wrote: > > Here's a related question: > > I can get the docstring for an imported module: > > >>> import tmpl as foo > > >>> print(foo.__doc__) > > Python templating features > > > > Author - tim at akwebsoft dot com > > > > ## Is it possible to get the module docstring > > ## from the module itself? > > > print __doc__ Thanks Carl. Where is general documentation on the subject of variables beginning with 2 underscores? I'm presuming the key phrase is 'builtin variables'. I'm searching too ... -- Tim tim at johnsons-web dot com or akwebsoft dot com http://www.akwebsoft.com
[toc] | [prev] | [next] | [standalone]
| From | Chris Rebert <clp2@rebertia.com> |
|---|---|
| Date | 2011-07-10 17:09 -0700 |
| Message-ID | <mailman.866.1310342970.1164.python-list@python.org> |
| In reply to | #9195 |
On Sun, Jul 10, 2011 at 5:00 PM, Tim Johnson <tim@johnsons-web.com> wrote: > * Carl Banks <pavlovevidence@gmail.com> [110710 15:18]: >> On Sunday, July 10, 2011 3:50:18 PM UTC-7, Tim Johnson wrote: <snip> >> > ## Is it possible to get the module docstring >> > ## from the module itself? >> >> print __doc__ > Thanks Carl. > > Where is general documentation on the subject of variables > beginning with 2 underscores? > > I'm presuming the key phrase is 'builtin variables'. I'm searching > too ... I've never heard that phrase used to describe __doc__ or its friends. Look in the "underscore" section of the documentation index: http://docs.python.org/genindex-_.html Cheers, Chris
[toc] | [prev] | [next] | [standalone]
| From | Chris Rebert <clp2@rebertia.com> |
|---|---|
| Date | 2011-07-10 17:16 -0700 |
| Message-ID | <mailman.867.1310343387.1164.python-list@python.org> |
| In reply to | #9195 |
On Sun, Jul 10, 2011 at 4:06 PM, Corey Richardson <kb1pkl@aim.com> wrote:
> Excerpts from Carl Banks's message of Sun Jul 10 18:59:02 -0400 2011:
>> print __doc__
>>
>
> Python 2.7.1 (r271:86832, Jul 8 2011, 22:48:46)
> [GCC 4.4.5] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> def foo():
> ... "Docstring"
> ... print __doc__
> ...
>>>> foo()
> None
>>>>
>
>
> What does yours do?
The question Carl's code was in answer to was, slightly paraphrased:
"Is it possible to get a *module*'s docstring from within the module
itself?"
The question had nothing to do with *function* docstrings.
The interactive interpreter environment also isn't quite a true
module, so you can't give it a docstring or really test the relevant
feature there. Try this instead:
$ cat test.py
"""I am the docstring of the `test` module!"""
print("This module's docstring is:", __doc__)
$ python test.py
This module's docstring is: I am the docstring of the `test` module!
$
Cheers,
Chris
--
http://rebertia.com
[toc] | [prev] | [next] | [standalone]
| From | Tim Johnson <tim@johnsons-web.com> |
|---|---|
| Date | 2011-07-10 16:21 -0800 |
| Message-ID | <mailman.868.1310343713.1164.python-list@python.org> |
| In reply to | #9195 |
* Chris Rebert <clp2@rebertia.com> [110710 16:14]: > > > > Where is general documentation on the subject of variables > > beginning with 2 underscores? > > I've never heard that phrase used to describe __doc__ or its friends. :) That why I wasn't satified with my search results. > Look in the "underscore" section of the documentation index: > http://docs.python.org/genindex-_.html And that is what I was looking for. thanks -- Tim tim at johnsons-web dot com or akwebsoft dot com http://www.akwebsoft.com
[toc] | [prev] | [next] | [standalone]
| From | Corey Richardson <kb1pkl@aim.com> |
|---|---|
| Date | 2011-07-10 20:26 -0400 |
| Message-ID | <mailman.869.1310344313.1164.python-list@python.org> |
| In reply to | #9195 |
[Multipart message — attachments visible in raw view] — view raw
Excerpts from Chris Rebert's message of Sun Jul 10 20:16:23 -0400 2011:
> The question Carl's code was in answer to was, slightly paraphrased:
> "Is it possible to get a *module*'s docstring from within the module
> itself?"
> The question had nothing to do with *function* docstrings.
>
Ah. My bad, thank you for clarifying.
--
Corey Richardson
"Those who deny freedom to others, deserve it not for themselves"
-- Abraham Lincoln
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web