How does "__doc__ % globals()" work?
Chris Angelico
rosuav at gmail.com
Mon Apr 12 19:00:38 EDT 2021
On Tue, Apr 13, 2021 at 8:57 AM Jaime <enopatch at gmail.com> wrote:
>
> Hi all. Line 102 of https://github.com/python/peps/blob/master/pep2html.py says:
>
> print(__doc__ % globals(), file=out)
>
> and I've just spent all day trying to understand "__doc__ %
> globals()".
The docstring for any function, class, or module, is available under
the name __doc__. It's a string, so what you're seeing is simply an
example of string formatting/interpolation, with the docstring
containing markers that get populated by globals.
ChrisA
More information about the Python-list
mailing list