On Wed, 08 Dec 2004 17:29:19 -0600, Greg Lindstrom wrote:

> One thought I had, which might lead to an addition to the language, was 
> to use the struct module.  If I could feed the pack method a format 
> string then a tuple of values (instead of individual values), then I 
> could create the format string once, then pass it a tuple with the 
> values for that record.  Just a thought. 

The language extension has been around since the early days. It was 
originally called 'apply'.  But now is called '*'.

>>> import struct
>>> fmt = '8s6s2s'
>>> v = ('foo','bar','AA')
>>> struct.pack(fmt,*v)
'foo\x00\x00\x00\x00\x00bar\x00\x00\x00AA'

-- 
              Stuart D. Gathman <[EMAIL PROTECTED]>
Business Management Systems Inc.  Phone: 703 591-0911 Fax: 703 591-6154
"Confutatis maledictis, flamis acribus addictis" - background song for
a Microsoft sponsored "Where do you want to go from here?" commercial.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to