Tino Dai wrote: > Is there a more pythonic way of doing this: > > if queuePacket.has_key('procSeq') and \ > queuePacket.has_key('opacSeq') and \ > queuePacket.has_key('keySeq') and \ > len(queuePacket['procSeq']) == 0 and \ > len(queuePacket['opacSeq']) == 0 and \ > len(queuePacket['keySeq']) == 0:
'procSeq' in queuePacket is a little better. You could put all the tests in a loop with all(): if all( (key in queuePacket and len(queuePacket[key]) == 0) for key in ('procSeq', 'opaqSeq', 'keySeq')): You could replace the test with something like len(queuePacket.get(key, 'xxx'))==0 which I think is equivalent though maybe a bit obscure... Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor