How does "__doc__ % globals()" work?
Jaime
enopatch at gmail.com
Mon Apr 12 18:06:12 EDT 2021
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()". Sure, I realise that globals() is a standard-library
built-in functions that returns a dictionary representing the current
global symbol table, and that the result of this expression is the
value of the dictionary where the key is "__doc__", but I can't
understand how this works.
I've searched through dictionary tutorials to see whether they mention
accessing dictionary values using a % (percent) operator, and they
don't.
I've searched through printf-string formatting tutorials, and they all
say that I need a %-sign to start, and then some parentheses, so it
can't be that either.
Can someone please put me out of my misery - what, exactly, is the
percent (%) sign doing in the expression "__doc__ % globals()"?
Thank you!
More information about the Python-list
mailing list