A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2014-January/131648.html below:

[Python-Dev] PEP 461 - Adding % and {} formatting to bytes

[Python-Dev] PEP 461 - Adding % and {} formatting to bytes [Python-Dev] PEP 461 - Adding % and {} formatting to bytesEthan Furman ethan at stoneleaf.us
Wed Jan 15 22:32:01 CET 2014
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~
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4