[Python-Dev] transitioning from % to {} formatting (original) (raw)
Nick Coghlan ncoghlan at gmail.com
Sun Oct 4 10:03:24 CEST 2009
- Previous message: [Python-Dev] transitioning from % to {} formatting
- Next message: [Python-Dev] transitioning from % to {} formatting
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Vinay Sajip wrote:
Nick Coghlan <ncoghlan gmail.com> writes:
I'm starting to think that a converter between the two format mini-languages may be the way to go though.
fmtbraces is meant to provide a superset of the capabilites of fmtpercent, so a forward converter shouldn't be too hard. A reverse converter may have to punt with ValueError when it finds things that cannot be expressed in the fmtpercent mini language though. I've done a first cut of a forward (% -> {}) converter: http://gist.github.com/200936 but I'm not sure there's a case for a converter in the reverse direction, if we're encouraging movement in one particular direction.
It would allow an application to still use brace formatting throughout even if one particularly library only accepted percent formatting. Probably not worth the effort at this point though, as if we can get a reliable forward converter happening then it may become possible for APIs to correctly guess which kind of format string they have been passed.
Cheers, Nick.
-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
- Previous message: [Python-Dev] transitioning from % to {} formatting
- Next message: [Python-Dev] transitioning from % to {} formatting
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]