Extract String From Enclosing Tuple
- From: rshepard@xxxxxxxxxxxxxxxxxxxxxx
- Date: 28 Feb 2007 20:40:29 GMT
I'm a bit embarrassed to have to ask for help on this, but I'm not finding
the solution in the docs I have here.
Data are assembled for writing to a database table. A representative tuple
looks like this:
('eco', "(u'Roads',)", 0.073969887301348305)
Pysqlite doesn't like the format of the middle term:
pysqlite2.dbapi2.InterfaceError: Error binding parameter 1 - probably
unsupported type.
I want to extract the 'Roads', part from the double-quoted enclosing
tuple. The unicode part should be automatically removed when the string is
printed, but I suspect it's the double quotes and extra parentheses that are
the problem. I know that tuples are immutable, but I thought that I could
slice it. If so, I'm not doing it correctly, because each attempt results in
TypeError: unsubscriptable object
Even when I assign that middle term to a variable before assembling the
tuple for insertion in the database, I just cannot get the job done. Whether
in the tuple of three terms or by itself, I haven't applied the proper
technique.
Insight appreciated.
Rich
.
- Follow-Ups:
- Re: Extract String From Enclosing Tuple
- From: Ben Finney
- Re: Extract String From Enclosing Tuple
- From: attn . steven . kuo
- Re: Extract String From Enclosing Tuple
- From: Bruno Desthuilliers
- Re: Extract String From Enclosing Tuple
- Prev by Date: How to check for remaining hard drive space in Windows?
- Next by Date: New to Tkinter GUI building
- Previous by thread: How to check for remaining hard drive space in Windows?
- Next by thread: Re: Extract String From Enclosing Tuple
- Index(es):