[docs] String formatting: "%#17.5l%" % ()
Edward Welbourne
eddy at opera.com
Wed Jan 25 11:29:16 CET 2012
Hi doc folks,
I was checking on the format-specifier grammar:
http://whorl/doc/python-doc/html/library/stdtypes.html#string-formatting
and noticed that it allows flag, field width, precision and length
modifier in a %% format specifier. I was about to report this as a bug
(as I expected the same rule ANSI C '89 imposed - for the % specifier,
the whole format specifier must be just %%, with no extras) but checked
in a python session:
>>> '%#17.5l%'
'%#17.5l%'
>>> '%#17.5l% %s' % 'hello'
' % hello'
>>> '%#17.5l%' % ()
' %'
>>> '%#*.*l%' % (17, 5)
' %'
I am duly amused.
It occurred to me that others might be, too ;-)
Eddy.
More information about the docs
mailing list