and cannot be deduced from the documentation.
--
components: Interpreter Core
messages: 70822
nosy: blop
severity: normal
status: open
title: string formatting quirk using %.%
type: behavior
___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org
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
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
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:
Hi,
''%([]) doesn't raise exception
but
''%('') does
Can anyone explain me why??
rgds
Anurag
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
''%([]) doesn't raise exception
but
''%('') does
Can anyone explain me why??
That is a side-effect of duck-typing. The duck-type of an empty list is
indistinguishable from that of an empty dictionary. Not testing the exact
type here achieves consistency with the