Is there a more elegant way to do this?

Shalabh Chaturvedi shalabh at cafepy.com
Sat Jun 26 18:44:26 EDT 2004


Kamilche wrote:
> '''
> Is there a more elegant way of doing this?
> I would like to have the arguments to pack
> automatically taken from lst.
> '''
> 
>     def pack(self):
>         lst = ['id', 'parent', 'number', 'x', 'y', 'z', 'red', \
>                    'green', 'blue', 'size', 'rotate', 'translucency']
>         return struct.pack('<IIIiiiBBBHHH', \
>                            self.id, self.parent, self.number,   \
>                            self.x, self.y, self.z,  \
>                            self.red, self.green, self.blue, \
>                            self.size, self.rotate, self.translucency)

Note that you don't have to use backslashes when you're inside any kind 
of brackets. Makes it look a little cleaner.

--
Shalabh





More information about the Python-list mailing list