[Tutor] using in over several entities
Alan Gauld
alan.gauld at btinternet.com
Fri Aug 24 19:11:29 CEST 2007
"Tino Dai" <tinoloc at gmail.com> wrote
> dbs= ['oracle','mysql','postgres','infomix','access']
>
> and we wanted to do this:
>
> if 'oracle' in dbs or 'mysql' in dbs or 'bdb' in dbs:
> <... do something ...>
>
> Is there a short way or writing this? Something like
> ('oracle','mysql','bdb') in dbs
You could use sets and check the intersection:
dbs = set(['oracle','mysql','postgres','infomix','access'])
test = set(['oracle','mysql','dbd'])
if dbs.intersection(test):
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld
More information about the Tutor
mailing list