Engineering numerical format PEP discussion

Mark Dickinson dickinsm at gmail.com
Tue Apr 27 01:53:35 CEST 2010


On Apr 26, 4:36 am, Keith <keith.braff... at gmail.com> wrote:
> I am considering writing a PEP for the inclusion of an engineering
> format specifier, and would appreciate input from others.

> [...]

> I am thinking that if we simply added something like %n (for eNgineer)
> to the list of format specifiers that we could make life easier for
> engineers:
>
> ("%n" % 12345)  == "12.345e+03"
> ("%n" %  1234)  == "1.234e+03"
> ("%n" %   123)  == "123e+00"
> ("%n" % 1.2345e-5)  == "12.345e+06"

I don't think there's much chance of getting changes to old-style
string formatting accepted;  you might be better off aiming at the new-
style string formatting.  (And there, the 'n' modifier is already
taken for internationalization, so you'd have to find something
different. :)

--
Mark



More information about the Python-list mailing list