[Tutor] Re: Searching string value in db

Doug.Shawhan@gecits.ge.com Doug.Shawhan@gecits.ge.com
Wed Nov 27 15:05:01 2002


Hmmm... I think it does.

for each in db.keys():
	print db[each]

returns all the values.

Crud. this is confusing.

-----Original Message-----
From: Derrick 'dman' Hudson [mailto:dman@dman.ddts.net]
Sent: Wednesday, November 27, 2002 2:08 PM
To: tutor@python.org
Subject: [Tutor] Re: Searching string value in db


On Wed, Nov 27, 2002 at 02:32:45PM -0500, Doug.Shawhan@gecits.ge.com wrote:
| I have a database in the following format:
| 
| 'key' : 'FOO, data, data' <--Regular old string with commas...
| 
| however: 
| 
| >>> for each in db.keys():
| 	if string.find(db[each], 'FOO') != -1:
| 		print each, db[each]
| 
| returns empty. 

I suspect that the object 'db' doesn't contain what you think it does.

Try
    print repr(db)
and see if any of the values contain the string "FOO".

Your usage of string.find() is correct.

-D

-- 
Microsoft has argued that open source is bad for business, but you
have to ask, "Whose business? Theirs, or yours?"     --Tim O'Reilly
 
http://dman.ddts.net/~dman/