Hi Rob,

On 30 June 2010 07:16, Rob Healey <robhealey1@gmail.com> wrote:
Greetings All:

I would like to use the any command, but I do not know how yet?  Here is my situation:

I have two loops to look through:
1) list of person handles -- a small list
2) ind_list which is all of the person handles in the NarrativeWeb report

If person in #1 is found in l#2, break and return True else return False

the list variable for #1, is handlelist
the list variable for #2, is _individuallist




Could you not just use sets?
eg:

overlap = set(handlelist) & set(_individuallist)

That'd give you the actual handles that are in *both*.

If you really want a true/false value, then you can do something like:

bool( set(handlelist) & set(_individualist) )

Using any would be something like:

result = any( handle in handlelist for handle in _individuallist )

Again, converting handlelist into a set would be potentially be good for performance.


hth

Jon.