[Python-3000] String formating operations in python 3k

Ian Bicking ianb at colorstudy.com
Thu Apr 6 03:20:01 CEST 2006


Greg Ewing wrote:
> Ian Bicking wrote:
>>> ** can't be changed in this way, either -- it really has to enumerate 
>> all the keys in the thing passed to it,
>> In Py3k this could perhaps be different in the case where
> you're calling a function defined like
>> def f(*args, **kwds):
> ...
>> In that case there are no named arguments to look up
> in the dict, so when it's called using
>> f(**obj)
>> the obj could be passed straight through to the kwds
> argument.

I thought of that, but that seemed much too clever. For instance, if 
you then change the signature to:
 f(a, **obj)
Then it doesn't work anymore, because you have to test if a keyword of 
'a' was passed in. ** in the signature and ** in the call are really 
not very symmetric.
With current substitution this isn't that big a deal, because you have 
either positional *or* named markers (or for string.Template positional 
are not allowed), and if you see any named marker you assume you were 
passed a dictionary-like object. Some of the proposals that mix {1} 
with {name} in the same substitution are harder. Also, they have to 
look at the name of the marker and see if it is an integer, and thus a 
dictionary with a key like '1' cannot be used.
-- 
Ian Bicking | ianb at colorstudy.com | http://blog.ianbicking.org


More information about the Python-3000 mailing list

AltStyle によって変換されたページ (->オリジナル) /