Confused by "format requires a mapping"
Fredrik Lundh
fredrik at pythonware.com
Sun Apr 9 03:03:22 EDT 2006
contact.morrison at gmail.com wrote:
> I'm very new to Python, and unsure how to handle this runtime error
> below. Pointers in the right direction (RTFM here ... etc) most
> appreciated.
>
> I have an object, called article, that when printed has the following
> structure:
>
> {'title': 'wbk', 'entries': [('http://wbk.opendarwin.org/blog/?p=51',
> 1), ('http://wbk.opendarwin.org/blog/?p=48', 1),
> ('http://wbk.opendarwin.org/blog/?p=50', 1),
> ('http://wbk.opendarwin.org/blog/?p=49',1),
> ('http://wbk.opendarwin.org/blog/?p=45', 1),
> ('http://wbk.opendarwin.org/blog/?p=44', 1),
> ('http://wbk.opendarwin.org/blog/?p=43', 1),
> ('http://wbk.opendarwin.org/blog/?p=42', 1),
> ('http://wbk.opendarwin.org/blog/?p=41',1),
> ('http://wbk.opendarwin.org/blog/?p=40',
> 1)]}('http://wbk.opendarwin.org/blog/?p=51', 1)
> DEBUG: Above was a dump of article, prior to "return
> unicode("%(title)s"%article)"
>
> As mentioned in the DEBUG output, my code now returns the following
> string:
>
> unicode("%(title)s"%article)
>
> However, that appears to conflict with article's structure, and i don't
> know why? I'm probably missing something fundamental with Python's
> syntax?
the debug output shows a dictionary followed by a tuple, rather than a
single value. maybe you should doublecheck what you're really passing
to the % formatting operator...
</F>
More information about the Python-list
mailing list