check for dictionary keys

micklee74 at hotmail.com micklee74 at hotmail.com
Sat Jun 3 03:30:30 CEST 2006


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.




More information about the Python-list mailing list