[Python-Dev] Re: Update PEP 292
Brett C.
bac at OCF.Berkeley.EDU
Tue Aug 24 19:39:25 CEST 2004
Anders J. Munch wrote:
>>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
>
That is not a fair comparison. First off, to make it fair, you would
need to make it ``%(1,000,000)s`` to compare to what $-interpolation is
doing.
Second, the whole point of this discussion is ease of use and thus
%-interpolation is not even worth comparing to. If it was we wouldn't
be bothering with this.
> 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.
>
It is not solving the idea of using a dictionary to key to values that
are to interpolated. It is to use a simpler syntax to represent the
text to be interpolated.
> 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]".
>
This was all discussed and rejected. $ is used in so many other
languages that there is the perk of familiarity to other languages.
And in terms of backwards-compatibility, that is not an issue since this
is all being put into a self-contained class and not into the str type.
All of this has been discussed long ago and settled on. At this point
the only thing left to do is to tell Barry his patch is fine and to just
apply the sucker. =)
-Brett
More information about the Python-Dev
mailing list