[Python-ideas] real numbers with SI scale factors: next steps
Paul Moore
p.f.moore at gmail.com
Tue Aug 30 17:07:17 EDT 2016
On 30 August 2016 at 21:34, Ken Kundert <python-ideas at shalmirane.com> wrote:
> So, given all this, I would like to make the following recommendations:
> 1. No action should be taken.
> 2. The main justification to modifying float() was to make it consistent with
> the extended Python language. Without extension 1, this justification goes
> away. However the need to be able to easily convert strings of numbers with
> SI scale factors into floats still exists. This should be handled by adding
> a library or extending an existing library.
> 3. Allowing numbers to be formatted with SI prefixes is useful and not
> controversial. The 'r' and 'b' format codes should be added to the various
> string formatting mechanisms.
>
> What do you think?
Thanks for the summary (which I mostly elided) which I think was fair.
Regarding (3), the only one that remains proposed, I think it would be
useful to see a 3rd-party library implementation of the formatting
operation proposed. This would allow any corner cases or controversial
points to be ironed out before proposing it for direct incorporation
in the string formatting mini-language. Furthermore, in Python 2.6, it
will be possible to write
f"The value is {si_format(the_val)}"
directly, using PEP 498 f-strings. The combination of a 3rd party
function and f-strings may even make special formatting support
unnecessary - but that will be easier to establish with practical
experience. And there's little or no downside - the proposed feature
won't be possible before 3.7, so we may as well use lifetime of the
3.6 release to gain that experience.
Paul
More information about the Python-ideas
mailing list