[Python-ideas] string.Template v2

Chris Angelico rosuav at gmail.com
Fri Nov 29 06:23:40 CET 2013


On Fri, Nov 29, 2013 at 3:55 PM, Stephen J. Turnbull <stephen at xemacs.org> wrote:
> I'd argue that the casual reader most likely doesn't actually care
> about the formatting, especially in in the running text case.  YMMV,
> but I'd bet on that, and would take the current formatting with
> keyword arguments for content and short moderately mnemonic codes for
> style as "most readable" for the cases where the styling of
> presentation matters.

Definitely. Focus should be on the overall string and its contents, it
shouldn't be screaming at you "HEY LOOK I'M ABOUT TO PUT A FLOAT IN
HERE WITH TWO DECIMALS". A simple, compact notation helps with that.

Anyway, if you can't figure out what ".2f" means, you're going to have
trouble in a lot of format languages that derive from printf. It's a
handy notation, and no harder to figure out than a more verbose
"type=float" is. After all, what does "float" mean? Will it render in
exponential notation? Decimal notation? Presumably it won't output the
IEEE binary representation, eg "40 49 0f db" (compacted into hex for
convenience), though it's plausible there might be a way to emit that.
So if you can learn the specifics of the "float" representation, you
should be able to learn the specifics of the "f" renderer. Same thing,
less keystrokes.

ChrisA


More information about the Python-ideas mailing list