[Python-3000] Proposed changes to PEP3101 advanced string formatting -- please discuss and vote! (original) (raw)

Jim Jewett jimjjewett at gmail.com
Sat Mar 17 01:09:49 CET 2007


On 3/13/07, Josiah Carlson <jcarlson at uci.edu> wrote:

"Patrick Maupin" <pmaupin at gmail.com> wrote: > Feature: Alternate syntaxes for escape to markup.

> this method "{foo}" escapes to markup, but when there is whitespace > after the leading "{", e.g. "{ foo}", the brace is not an escape to > markup. If the whitespace is a space, it is removed from the output, > but if it is '\r', '\n', or '\t', then it is left in the output.

I can see it being very useful. But if I'm using strings that long, and ready to be picky about whitespace -- I'm ready to import a module. To me, this looks like a good example Template extension.

can't help but think that %var% would be a better alternate explicit

Some of the same documents that have lots of "{" characters will have lots of "%". Again, Template will let you change the identifier character quite easily.

> Feature: Ability to insert non-printing comments in format strings

The user can use the parser/compiler to get this behavior for free.

(" text " #your comment here "more text").format(...)

If the only alternative were really to push more on eval and to obfuscate code (did you mean to stick those together, or did you forget a comma?) ... I would support this.

Since we do already have String.template, maybe the answer is to somehow promote it.

-jJ



More information about the Python-3000 mailing list