473,804 Members | 2,180 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Confused by "format requires a mapping"

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("%(titl e)s"%article)"

As mentioned in the DEBUG output, my code now returns the following
string:

unicode("%(titl e)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.articlemen u.set_list(
File "wbk.py", line 240, in format_article_ title
return unicode("%(titl e)s"%article)
TypeError: format requires a mapping

Apr 9 '06 #1
1 4545
co************* *@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("%(titl e)s"%article)"

As mentioned in the DEBUG output, my code now returns the following
string:

unicode("%(titl e)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>

Apr 9 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
13870
by: Geoffrey | last post by:
Hope someone can help. I am trying to read data from a file binary file and then unpack the data into python variables. Some of the data is store like this; xbuffer: '\x00\x00\xb9\x02\x13EXCLUDE_CREDIT_CARD' # the above was printed using repr(xbuffer). # Note that int(0x13) = 19 which is exactly the length of the visible text #
0
25862
by: phmyhn | last post by:
I have two web pages, one is viewlarger.aspx, another one is shoppingcart.aspx. On the viewlarger.aspx, when clicking "add to cart" image button, the sub appends the id (passed from another page from a hyperlink column) into a session. the code is as following: Private Sub ibtAddtoCart_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ibtAddtoCart.Click idStr = Session("ids") pid =...
5
2214
by: Robin Tucker | last post by:
My database has a column for numeric data items. How can I use this number in the "format" command, such that for, say precision 2, I get numbers like 2011.01 or 2387.00 and for 4 I would get 2011.0100 or 2387.0000? (simple question I know!)
16
4025
by: Al Reid | last post by:
First, I'm using vb2005. I have a string that is read from a barcode reader into a TextBox. The string is 6 characters long and represents a date (mmddyy). I want to display it to the user in a date format of "mm/dd/yy" For example the barcode contains "112303" and I want to format it to display "11/23/03" If I use the microsoft.visualbasic.strings.format with a format string of "##/##/##" or "00/00/00" I get the format string in the...
1
1545
by: geri.gan | last post by:
I have C API just like this: enum void getinfor(const struct inputinfor *a, const struct outputinfor ** b) i use p/invok to translate it to internal static extern void getinfor(ref inputinfor a, ref
3
12945
by: Pieter Coucke | last post by:
Hi, When a user types a non numeric-value in a numeric column in a DataGridView, and he tries to leave the cell, he gets this "Input string was not in a correct format."-exception. Is there a (nice) way to get rid of this exception? And just put a "0" in the place? Or somehow trigger this single exception (does exceptions have a unique type-number?) and do some appropriate actions?
5
2172
by: veaux | last post by:
I'm thinking this is easy but can't get it. I have a table with following: Table1 Date 1/1/2007 Table2 Type 0107 (This is MMYY of above) So I'm having trouble using a query to turn the date from Table 1 into
13
10398
by: Jen | last post by:
One user of my application is experiencing an exception "input string not in correct format". But it makes no sense where it is occurring. It is occurring when a string from a textbox ("172") is being convert to an Int16 (using Convert.ToInt16). How can that be? There are other text boxes that are used in the identical fashion and they don't generate the exception. All there are many other machines running my application that don't...
2
4735
by: stainless | last post by:
I know this is probably simple but I cannot find a method of converting a date string into a format that matches the DatePicker format in C# eg string "20080131" converted to "31 January 2008" I tried datetime.parseexact but could not find the definition for the appropriate format string. This would be a very useful tool fo me. Any ideas,please?
0
9714
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10350
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10351
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7638
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6866
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5534
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4311
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.