[Tutor] Difference between %f and %F string formatting?
boB Stepp
robertvstepp at gmail.com
Wed Apr 26 22:33:59 EDT 2017
On Wed, Apr 26, 2017 at 9:19 PM, Tim Peters <tim.peters at gmail.com> wrote:
> [boB Stepp <robertvstepp at gmail.com>]
>> My Google-fu must be weak tonight.
>
> Look here:
>
> https://en.wikipedia.org/wiki/Printf_format_string
Thanks. From the %d versus %i links I found, I should have pursued
the C history more diligently for the %f versus %F question. My bad!
>> I cannot find any discernible
>> difference between '%f' % <some floating point number> and '%F' %
>> <some floating point number>. Is there any or do they duplicate
>> functionality? If the latter, why are there two ways of doing the
>> same thing?
>
> They differ only in the capitalization of the strings produced for
> NaNs and infinities (math.nan and math.inf in Python 3).
Hmm. I'm surprised this slight distinction was worth keeping two
format codes that otherwise do the same thing. Is there an actual
need for these due to Python being implemented behind the scenes in C?
--
boB
More information about the Tutor
mailing list