Function docstring as a local variable

Andrew Berg bahamutzero8825 at gmail.com
Sun Jul 10 19:47:17 CEST 2011


-----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__)
...
>>> test()
Hi there.

- -- 
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/

iQEcBAEBAwAGBQJOGeWlAAoJEPiOA0Bgp4/LT1EIAM32NS/RdZ9y6IlAkpEYkYeP
qGf2A/+8eZHrSYtCWYWwpfusa9guYaQsDvq31sFHnI3VPria7mUeB6HoyqP1sO3B
5D0lpBK0/u3rWNL9FHeWeb+Cc6CLXBB7531VAR1pzfUVb1mw3LPww16klNMkr5Gd
9Qob710lKIW+om8rEF+L5o/DOFSTN7oodTsNpdj8zhHVnPVpV/gtL7iQR82C0KPq
UuukVkCuhvYyWoJMz1qDZjKU1bI2T064TC8IeOQLdOVMnQLhTJdgsHD4nNVszixN
EU9eemscW0cABF2MgUPnuJLytUJHcxtEC4aj3Cue0oLhMyVN57yNIBaf1Pm6M7E=
=tCFP
-----END PGP SIGNATURE-----



More information about the Python-list mailing list