Georg Brandl <[EMAIL PROTECTED]> added the comment:
I'd rather see it this way: It is a programming error if a format string
contains a reference to a nonexisting dictionary key, no matter what
formatting specifier is used. The implementation is quite consistent here.
--
nosy: +georg.bra
nadav <[EMAIL PROTECTED]> added the comment:
The main problem with this is that the following code does not make any
sense:
"%(a)%" % dict(a=3)
It has no semantic meaning (take the dictionary paramater a, and do nothing
with it).
It must be a user bug (except in very wierd cases).
I agree that
Guido van Rossum <[EMAIL PROTECTED]> added the comment:
It's straightforward if you consider the implementation of the
requirement that %% renders a single percent sign: the second % is
parsed just like any other formatting code (i, d, f, etc.) and the stuff
between the first % and the formatting
New submission from nadav <[EMAIL PROTECTED]>:
>>> "%.%s" % ()
'%s'
>>> "%(a).%(b)s" % dict(a=2)
'%(b)s'
>>> "%(a).%(b)s" % dict(a=2, b=3)
'%(b)s'
>>> "%(a).%(b)s" % dict()
Traceback (most recent call last):
File "", line 1, in -toplevel-
"%(a).%(b)s" % dict()
KeyError: 'a'
this is counter