[Python-Dev] Re: PEP 292, Simpler String Substitutions

Barry A. Warsaw barry@wooz.org
Wed, 19 Jun 2002 07:10:10 -0400


>>>>> "KY" == Ka-Ping Yee <ping@zesty.ca> writes:

    KY> I assume you in fact meant

    KY> 	    return '${name} was born in ${country}'.sub()

    KY> for the third line above?

Yup, thanks for the fix.

    >> print s.sub({'name': 'Guido', 'country': 'the Netherlands'})

    KY> Have you considered the possibility of accepting keyword
    KY> arguments instead?

Nope, and it's not a bad idea.  I've added this in an "Open Issues"
section. 
    
    KY> If you decide to use keyword arguments, you can either allow
    KY> both keyword arguments and a single dictionary argument, or
    KY> you can just accept keyword arguments and people can pass in
    KY> dictionaries using **.

I'd prefer the latter, otherwise we'd have to pick a keyword that
would be off-limits as a substitution variable.

Thanks!
-Barry