def all(s): for x in s: if not x: return False return True
bad_combos = [['-A', '-B'], ['-A', '-C'], ...] for bad_combo in bad_combos: assert not all([bad_elem in a for bad_elem in bad_combo]) [EMAIL PROTECTED] wrote: > hi > in my code, i use dict(a) to make to "a" into a dictionary , "a" comes > from user input, so my program does not know in the first place. Then > say , it becomes > > a = { '-A' : 'value1' , '-B' : "value2" , "-C" : "value3" , '-D' : > 'value4' } > > somewhere next in my code, i will check for these..: > > 1) -A and -B cannot exist together > 2) -A and -C cannot exist together > 3) -A and -B and -D cannot exist together > 4) and lots of other combinations to check for.... > > how can i efficiently check for the above? At first as i do simple > checks , i use if and else. > But as i began to check for more combinatoiuns, it gets messy.... > > thanks. -- http://mail.python.org/mailman/listinfo/python-list