R
rshepard
I'm not sure how to change a string so that it matches another one.
My application (using wxPython and SQLite3 via pysqlite2) needs to compare
a string selected from the database into a list of tuples with another
string selected in a display widget.
An extract of the relevant code is:
selName = self.polTree.GetItemText(selID)
...
for item in self.appData.polNat:
print 'Item: ', item, '\n', 'selName: ', selName, '\n'
if item == selName:
print '***** ', self.appData.polNat[1]
The last comparison and print statement never work because the strings are
presented this way:
Item: (u'ground water',)
selName: ground water
What do I need to do to 'Item' to strip the parentheses, unicode symbol,
single quotes, and comma? Do I want 'raw' output? If so, how do I specify
that in the line 'if item == selName:'?
TIA,
Rich
My application (using wxPython and SQLite3 via pysqlite2) needs to compare
a string selected from the database into a list of tuples with another
string selected in a display widget.
An extract of the relevant code is:
selName = self.polTree.GetItemText(selID)
...
for item in self.appData.polNat:
print 'Item: ', item, '\n', 'selName: ', selName, '\n'
if item == selName:
print '***** ', self.appData.polNat[1]
The last comparison and print statement never work because the strings are
presented this way:
Item: (u'ground water',)
selName: ground water
What do I need to do to 'Item' to strip the parentheses, unicode symbol,
single quotes, and comma? Do I want 'raw' output? If so, how do I specify
that in the line 'if item == selName:'?
TIA,
Rich