[Tutor] Re: Searching string value in db

Derrick 'dman' Hudson dman@dman.ddts.net
Wed Nov 27 14:54:02 2002


--J2SCkAp4GZ/dPZZf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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

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

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

--J2SCkAp4GZ/dPZZf
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iEYEARECAAYFAj3lJg8ACgkQO8l8XBKTpRQVpgCgiSZ0bTpMycKCQVCpTh2/kVzA
MRkAoLltSdU79fM7b+p+zybw6wAMEbHn
=1nZw
-----END PGP SIGNATURE-----

--J2SCkAp4GZ/dPZZf--