Hi,
I typically use the string .lower() or .upper() for comparisons in which I
don't know case. However, I have also used a small function to convert
whatever's entered in a data entry widget using the widget's focus events.
Mike
···
-----Original Message-----
From: Rich Shepard [mailto:rshepard@appl-ecosys.com]
Sent: Sunday, February 11, 2007 12:42 PM
To: wxpython-users@lists.wxwidgets.org
Subject: Handling Case Differences
I've been hung up most of the weekend trying to get a trivial function to
work. It just occurred to me that the reason the equivalence comparison kept
failing, even when I saw the two strings were the same is that one string
has an initial uppercase, the other does not. Ergo, they're not equal.
If I try something like this:
for item in self.appData.varis:
if item[2].lower() == selName:
the comparison works, but then the next line fails:
print 'item[0]'. item[0]
because:
File "/data1/eikos/policyPage.py", line 208, in loadVars
print 'item[0]'. item[0]
AttributeError: 'str' object has no attribute 'item'
It looks to me that item[2].lower() cast the entire tuple to a single
string.
Is the most practical solution to write a validator that converts all
data strings to initial uppercase when they're entered into a data entry
widget? If so, is there such a validator -- with instructions for use --
already written somewhere?
How have others handled this situation of comparing data with different
cases?
Rich
--
Richard B. Shepard, Ph.D. | The Environmental Permitting
Applied Ecosystem Services, Inc. | Accelerator(TM)
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863