Use the .get method of the dict to return a nonzero value (say None or -1)
when it can't find an item. That will half your test cases. Example of .get
below:

     --Michael

>>> foo = {}
>>> foo['d']=0
>>> foo['a']=1
>>> if(foo.get('a',1)==0 and foo.get('q',1)==0): print foo
... else: print "adsflkj"
...
adsflkj
>>> foo['q'] = 0
>>> if(foo.get('a',1)==0 and foo.get('q',1)==0): print foo
... else: print "adsflkj"
...
adsflkj
>>> foo['a'] = 0
>>> if(foo.get('a',1)==0 and foo.get('q',1)==0): print foo
... else: print "adsflkj"
...
{'a': 0, 'q': 0, 'd': 0}
>>>




-- 
Michael Langford
Phone: 404-386-0495
Consulting: http://www.TierOneDesign.com/
Entertaining: http://www.ThisIsYourCruiseDirectorSpeaking.com

On 9/21/07, Tino Dai <[EMAIL PROTECTED]> 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

Reply via email to