There are quite a few ways to do what you want. Here's are a few variations on a theme:
try: if not any( ( len(queuePacket['procSeq']), len(queuePacket['opacSeq']), len(queuePacket['keySeq']) ) ): # Do your stuff here do_stuff() except KeyError: pass Or, using a generator: try: if not any( len(queuePacket[key]) for key in ( 'procSeq', 'opacSeq', 'keySeq' ) ): # Do your stuff here do_stuff() except KeyError: pass Or, using a list comprehension: try: if not [ 1 for key in ( 'procSeq', 'opacSeq', 'keySeq' ) if len(queuePacket[key]) != 0 ] ): # Do your stuff here do_stuff() except KeyError: pass 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: > > > ? > > -Thanks, > Tino > > ------------------------------------------------------------------------ > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor