Using an interable in place of *args?

Nick Vargish nav+posts at bandersnatch.org
Sat Nov 22 12:16:58 EST 2003


dw-google.com at botanicus.net (David M. Wilson) writes:

> Just random passing code commentary:
  [...]
>       for format, field in structure:
        [...]
> That avoids the triple iteration. The vars(self) call is unnecessary,
> I just think it looks cleaner. :)

Interestingly enough, I'd already swapped out the list comprehensions
for a single for loop. :^)

Some respondants seemed confused about what I was trying to do... I'm
communicating with a C program that generates datagrams from a C
structure. Many of the datagrams have, for the last two fields,
"unisigned int datasize; char data[]". I wanted a convenient way of
extracting the fields of known size, and the data blob at the end.

If others are interested in the class I've built, I can make it
available (maybe through the Cookbook web site) when it's a little
more mature.

Again, thanks for all the pointers. Although the language itself is
the first reason, the community is a close second for why I love
programming in Python.

Nick

-- 
#  sigmask  ||  0.2  ||  20030107  ||  public domain  ||  feed this to a python
print reduce(lambda x,y:x+chr(ord(y)-1),' Ojdl!Wbshjti!=obwAcboefstobudi/psh?')




More information about the Python-list mailing list