[Python-Dev] Re: PEP 292, Simpler String Substitutions
Guido van Rossum
guido@python.org
Wed, 19 Jun 2002 08:52:38 -0400
> Have you considered the possibility of accepting keyword arguments
> instead? They would be slightly more pleasant to write:
>
> print s.sub(name='Guido', country='the Netherlands')
>
> This is motivated because i imagine relative frequencies of use
> to be something like this:
>
> 1. sub() [most frequent]
> 2. sub(name=value, ...) [nearly as frequent]
> 3. sub(dictionary) [least frequent]
>
> If you decide to use keyword arguments, you can either allow both
> keyword arguments and a single dictionary argument, or you can
> just accept keyword arguments and people can pass in dictionaries
> using **.
I imagine that the most common use case is a situation where the dict
is already prepared. I think **dict is slower than a positional dict
argument. I agree that keyword args would be useful in some cases
where you can't trust the string.
--Guido van Rossum (home page: http://www.python.org/~guido/)