Cheat sheet for the new string formatting?

Skip Montanaro skip.montanaro at gmail.com
Tue Jun 9 09:13:41 EDT 2015


On Tue, Jun 9, 2015 at 7:29 AM,  <random832 at fastmail.us> wrote:
> Where have you looked? Have you read
> https://docs.python.org/3/library/string.html#formatspec ?

Yes, but I missed the None section. I looked closely at 'g', but
didn't see anything like "this is the default". I will admit I was a
bit frustrated to see things like the documentation for the format()
builtin indicating that it calls value.__format__, but then couldn't
find any documentation in the numeric types for float.__format__. From
the documentation of the format() builtin: "The interpretation of
format_spec will depend on the type of the value argument...", which
suggested to me that at least the builtin types would have some stub
documentation of their __format__ method, even if all it did was
redirect the user to the section in the string doc:
https://docs.python.org/3.5/library/string.html#format-string-syntax

I'll open a doc issue about that. Thanks for the help.

Skip



More information about the Python-list mailing list