On 9/21/07, Jerry Hill <[EMAIL PROTECTED]> wrote: > > 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: > > Assuming we're talking about Python 2.5 or greater I find the > following pretty readable: > > all(queuePacket.has_key(k) for k in ('procSeq', 'opacSeq', 'keySeq')) and > \ > all(len(queuePacket[k])==0 for k in ('procSeq', 'opacSeq', 'keySeq'))
You can do that in Python?!?!!! That kicks major a......well, this is a family list. Thanks for that. I really had no idea that you could do that kind of syntax structure. Now, I have a bunch of code that I can go and make a lot shorter and more readable Thanks, Tino
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor