Newbie Q on searching lists

Kenny Tilton ktilton at nyc.rr.com
Sat Nov 23 10:58:10 EST 2002


Patrick W wrote:
> Kenny Tilton <ktilton at nyc.rr.com> writes:
> 
> 
>>>>1. Am I missing something?
>>>>
>>>
>>>if calculators.count(thisCalculator): # returns zero if not found
>>>   raise CircularDependency, thisCalculator
>>
>>oops :)  thx!
> 
> 
> Try this:
> 
> if thisCalculator in calculators:
>         do_stuff()
> 
> Tests of the form '<item> in <sequence>' work for dictionaries
> (hashtables), strings and tuples as well as lists.

ah, that was my problem. i had looked only at list operations, not yet 
grokking the umbrella sequence quality. thx much.

-- 

  kenny tilton
  clinisys, inc
  ---------------------------------------------------------------
""Well, I've wrestled with reality for thirty-five years, Doctor,
   and I'm happy to state I finally won out over it.""
                                                   Elwood P. Dowd




More information about the Python-list mailing list