[Python-Dev] PEP 292: method names
Erik Heneryd
erik at heneryd.com
Mon Sep 13 18:18:28 CEST 2004
Barry Warsaw wrote:
> On Sat, 2004-09-11 at 09:04, Erik Heneryd wrote:
>
>
>>Come to think of it, I really like the more OO-ish approach better, than
>>to cram everything into a single class. Is the safe_substitute really
>>that special it deserves a special method?
>
>
> Yes.
>
>
>> Is it really the one, true
>>way to do a "safe" substitution?
>
>
> Probably not.
>
>
>>IIRC DOS and sh don't agree, so it's
>>not that obvious.
>
>
> I'm sorry I don't follow that one.
DOS: '%NOTFOUND%' => '%NOTFOUND%'
sh: '$NOTFOUND' => ''
BTW, what about a closing delimiter in the standard regex?
>>I say keep the inheritance thing, it's much more flexible, and delegate
>>the KeyError condition to an overridable method.
>
>
> After the lengthy discussions on python-dev, I'm viewing the role of the
> Template class a little differently, so I think it's fine to put them
> both in one class.
I think there are more use cases for a KeyError hook than just sh-style
substitution; a default value, a computed value (think replacing html
entities - returning chr(idpattern) on KeyError) etc...
I hope you don't do pep-292 just to fill your own needs (i18n?), but
also keep your mind open to other uses...
Erik
More information about the Python-Dev
mailing list