Formatting floating point

DL Neil PythonList at DancesWithMice.info
Wed Sep 4 18:05:19 EDT 2019


On 5/09/19 5:12 AM, Dave via Python-list wrote:
...

> My question is why, and where do I find a reliable source of information 
> on formatting numbers?  Not interested in replacement values like '{} 
> {}'.format(1, 2).


Agreed: there's ton(ne)s of information 'out there', much of it old, eg 
Python2, "formatter" (deprecated since v3.4), methods pre-dating 
f-strings, etc; and more of it rather casually thrown-out-there. 
Learning from StackOverflow (etc) has its limits/perils!

Authoritative Python docs: https://docs.python.org/3/
The "Mini-Language": 
https://docs.python.org/3/library/string.html#formatspec

Current advice (v3.6+) is to study the newer f-strings (formally 
"formatted string literals"): 
https://docs.python.org/3/tutorial/inputoutput.html which came from PEP 
498: https://www.python.org/dev/peps/pep-0498/

-- 
Regards =dn



More information about the Python-list mailing list