Bugs item #1467929, was opened at 2006-04-10 19:39 Message generated for change (Comment added) made by gbrandl You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1467929&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Interpreter Core Group: Python 2.5 Status: Open Resolution: None Priority: 5 Submitted By: M.-A. Lemburg (lemburg) >Assigned to: Martin v. Löwis (loewis) Summary: %-formatting and dicts Initial Comment: This looks like a bug in the way the %-formatting code works or is it a feature ? >>> '%s %(a)s' % {'a': 'xyz'} "{'a': 'xyz'} xyz" >>> u'%s %(a)s' % {'a': 'xyz'} u"{'a': 'xyz'} xyz" Note that both strings and Unicode are affected. Python 2.3 and 2.4 also show this behavior. I would have expected an exception or the %-formatter simply ignoring the first %s. ---------------------------------------------------------------------- >Comment By: Georg Brandl (gbrandl) Date: 2006-07-24 13:37 Message: Logged In: YES user_id=849994 The library ref specifies that if a dict is supplied, the format specifiers MUST include a mapping key, so the right thing to do would be to raise an exception. Is it worth breaking backwards compatibility, Martin? ---------------------------------------------------------------------- Comment By: Hasan Diwan (hdiwan650) Date: 2006-04-14 08:33 Message: Logged In: YES user_id=1185570 It looks as though it's a feature... The first %s will print the whole dictionary as a string, the second, only that value looked up by the key. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1467929&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com