On 8/10/19 4:04 AM, boffi wrote:
DL Neil <pythonl...@danceswithmice.info> writes:
Agreed: there's ton(ne)s of information 'out there', much of it old,
eg Python2, "formatter" (deprecated since v3.4)
?
are you referring to the `string.Formatter`[*] class?
$ python
Python 3.7.4 (default, Aug 13 2019, 20:35:49)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from string import Formatter
if not, what else?
g
[*] https://docs.python.org/2/library/string.html#string.Formatter
https://docs.python.org/3.7/library/string.html#string.Formatter
As mentioned, there is a wealth of information, but I must admit it took
a moment-or-two before I re-located the 'official' reference to f-strings:
2.4.3. Formatted string literals
https://docs.python.org/3/reference/lexical_analysis.html#f-strings
(and please 'read-around' this section for more valuable data!)
FYI the original PEP is at https://www.python.org/dev/peps/pep-0498/
It is worth reading about string formatters (per (your) ref, above),
because many elements of the 'Formatting mini-language' are also
available within f-strings!
As you have probably observed, there are now (v3.6+) several methods
which can be applied to the formatting of data. Each has its advantages,
and whilst I have a preference for, and thus recommended, WRITING code
to use f-strings, it is also (likely to be) important that we READ and
comprehend the older/alternatives!
NB politesse suggests that I should apologise, but I no-longer wish to
work with Python2; hence only mentioning Py3 'here'.
--
Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list