[Python-ideas] Customizing format()
python at rcn.com
Tue Mar 17 23:25:18 CET 2009
> I strongly prefer suffix to prefix modification.
Given the way that the formatting parsers are written,
I think suffix would work just as well as prefix. Also,
your idea may help with the mental parsing as well
(because the rest of the format string uses the
untranslated symbols so that translation pairs should
be at the end).
>> Also, this version makes it easy to employ a couple of techniques to
> These techniques apply to any "augment the basic format with an
> affix" method.
> I also prefer, mnemonic key letters to mark the start of each affix,
> format(1234, '8.1f;T.;P,')
I think it's better to be explicit that periods are translated to commas
and commas to periods. Introducing a new letter just adds more to
more memory load and makes the notation more verbose. In the
previous newgroup discussions, people reacted badly to letter
mnemonics finding them to be so ugly that they would refuse to
use them (remember the early proposal of format(x,"8T,.f)).
Also, the translation pairs approach lets you swap other hardwired
characters like the E or a 0 pad.
More information about the Python-ideas