[Python-Dev] Re: Update PEP 292

Brett C. bac at OCF.Berkeley.EDU
Fri Aug 20 18:29:00 CEST 2004


Barry Warsaw wrote:

> On Thu, 2004-08-19 at 19:12, Brett C. wrote:
> 
> 
>>Got an implementation and it's simple.  =)  It only required one 
>>additional group at the end (r"(?<!\$)(\$)$") in the regex and a test if 
>>it matched.
>>
>>I tested against "$$" to be fine but for "blah $" and "$" to raise an 
>>exception.  Those all work and the tests in test_pep292 all pass.
> 
> 
> What do you think about this compared to Tim's pattern, which is more
> strict than just complaining about $'s at the end of strings?
> 

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?

"Explicit is better than implicit" is good since it will cut down on 
errors (which is what Tim is arguing for along with "Special cases 
aren't special enough to break the rules").

But Raymond is pushing for "practicality beats purity" which is more or 
less true, but I am starting to agree with Tim that dollar amounts in an 
interpolated string probably won't hapeen that often.  If anything the 
number will be what is interpolated in.  So going for a more explicit 
version is seeming to be the better solution.  Perk of the current 
implementation is that if someone wants a looser definition they can 
just change the regex themselves (you guys could even go as far as to 
break up the regex into individual class attributes and just have a 
property that does a '|'.join on them as a read method so it is even 
easier to just change the one group).

So I guess it's your call, Mr PEP Champion, on whether you want all 
individual, non-interpolating $ signs to lead to an error or just random 
orphaned ones at the end of the line.

-Brett



More information about the Python-Dev mailing list