On 01/15/2014 06:45 AM, Brett Cannon wrote:
The PEP currently says::
format
------
The format mini language will be used as-is, with the behaviors as listed
for %-interpolation.
That's too vague; % interpolation does not support other format operators in
the same way as str.format() does. %
interpolation has specific code to support %d, etc. But str.format() gets
supported for {:d} not from special code but
because e.g. float.__format__('d') works. So you can't say "bytes.format()
supports {:d} just like %d works with string
interpolation" since the mechanisms are fundamentally different.
A question for anyone that has extensive experience in both %-formatting and .format-formatting: Would it be possible,
at least for int and float, to take whatever is in the specifier and convert to %? Example:
"Weight: {wgt:-07f}".format(wgt=137.23)
would take the "-07f" and basically do a "%-07f" % 137.23 to get the ASCII to
use?
--
~Ethan~
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com