[Python-Dev] transitioning from % to {} formatting (original) (raw)
Guido van Rossum guido at python.org
Wed Oct 7 05:44:36 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 ]
On Fri, Oct 2, 2009 at 6:29 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
Has anyone considered the idea of having the string % operator behave intelligently according to the contents of the format string?
If it contains one or more valid %-formats, use old-style formatting; if it contains one or more valid {}-formats, use new-style formatting. Ambiguous cases could arise, of course, but hopefully they will be fairly rare, and raising an exception would point out the problem and allow it to be fixed.
Hm... The % operator already does too much guessing: if the string contains exactly one %-format, the argument may be either a size-1 tuple or a non-tuple, otherwise it has to be a size-N tuple, except if the %-formats use the %(name)X form, then the argument must always be a dict. It doesn't sound to me as if adding more guesswork is going to improve its reliability.
-- --Guido van Rossum (home page: http://www.python.org/~guido/)
- Previous message: [Python-Dev] transitioning from % to {} formatting
- Next message: [Python-Dev] transitioning from % to {} formatting
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]