Newbie Q on searching lists

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


Terry Hancock wrote:
> On Friday 22 November 2002 10:21 pm,  Kenny Tilton wrote:
> 
>>The semantics I am coding happen to throw an error if a certain element 
>>is found in a list, so i want to code:
>>
>>    if calculators.index[thisCalculator]:
>>       raise CircularDependency, thisCalculator
> 
> 
> Did you mean this?
> 
> if thisCalculator in calculators:
>         raise CircularDependency(thisCalculator)

sweet. thx. for the heads up on custom exceptions as well. I was faking 
that bit (as you could tell <g>), just wanted to put up a more readable 
example.

-- 

  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