Confused by "format requires a mapping"

contact.morrison at gmail.com contact.morrison at gmail.com
Sun Apr 9 00:36:46 EDT 2006


Hello,

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?

TIA
Morrison

Traceback (most recent call last):
  File "C:\APPS\pys60\s60-compat\appuifw.py", line 287, in OnSelect
    self.callback()
  File "wbk.py", line 189, in handle_feedmenu_select
    self.goto_state('articlemenu')
  File "wbk.py", lineA 156, in goto_state
    self.articlemenu.set_list(
  File "wbk.py", line 240, in format_article_title
    return unicode("%(title)s"%article)
TypeError: format requires a mapping




More information about the Python-list mailing list