Is there a more elegant way to do this?

Jeff Epler jepler at unpythonic.net
Sat Jun 26 18:15:15 EDT 2004


something like this:
>     def pack(self):
>         lst = ['id', 'parent', 'number', 'x', 'y', 'z', 'red', \
>                    'green', 'blue', 'size', 'rotate', 'translucency']
          values = [getattr(self, attr) for attr in lst]
          return struct.pack('<IIIiiiBBBHHH', *values)

Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20040626/9c5820f4/attachment.sig>


More information about the Python-list mailing list