[issue6396] No conversion specifier in the string, no __getitem__ method in the right hand value
Martin v. Löwis
report at bugs.python.org
Thu Jul 2 08:00:45 CEST 2009
Martin v. Löwis <martin at v.loewis.de> added the comment:
No, it's not logical that there should be an exception. The result looks
right to me.
You are incorrectly assuming that it would always invoke __getitem__ in
this case, which is not true:
py> "a string with a single placeholder: %s" % c
'a string with a single placeholder: <__main__.AClass object at 0xb7d3b1ec>'
So whether it requires c to be a dictionary depends on whether there are
any %(foo)s conversions in the string. With no conversion specifiers,
the values passed to % are irrelevant.
----------
nosy: +loewis
resolution: -> invalid
status: open -> closed
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6396>
_______________________________________
More information about the Python-bugs-list
mailing list