[Python-Dev] Re: Update PEP 292 (original) (raw)

Anders J. Munch ajm at flonidan.dk
Tue Aug 24 13:42:06 CEST 2004


From Brett C. [mailto:bac at OCF.Berkeley.EDU]

That is coming down to a question of convenience compared to explicitness. Do we want "Give me $1,000,000 now!" to raise ValueError, or do we want to let it pass through?

This particular problem has been considered and decided on years ago, in the context of %-interpolation:

>>> "Give me %1,000,000 now!" % {}
ValueError: unsupported format character ',' (0x2c) at index 10

String interpolation with named parameters given as a dictionary is a problem already solved in Python. I am puzzled at this urge to re-solve the same problem, only differently.

If remembering to type the trailing s in "%(varname)s" is so much of a problem, why not extend the current interpolation syntax with a variation that is more convenient, yet still backwards-compatible? I would suggest a formatting-character-less version of "%(varname)s" that uses brackets instead: "%[varname]".

dollar-signs?-we-don't-need-no-steenkin-dollar-signs-ly y'rs, Anders



More information about the Python-Dev mailing list