kutsurak / python-bitstring

Automatically exported from code.google.com/p/python-bitstring
0 stars 0 forks source link

pack should accept an iterable as the format #117

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The pack function needs a string as the format, which isn't consistent with 
unpack and readlist, both of which will accept a (non-string) iterable.

This breaks symmetry between pack and unpack, for example you'd expect to be 
able to do this:

    fmt = ['hex:8', 'bin:3']
    a = pack(fmt, '47', '001')
    a.unpack(fmt)

but instead you would need to write

    a = pack(','.join(fmt), '47', '001')

which is ugly for a number of reasons...

Original issue reported on code.google.com by dr.scott...@gmail.com on 28 Aug 2011 at 9:20

GoogleCodeExporter commented 9 years ago
Fixed in r.921.

Original comment by dr.scott...@gmail.com on 29 Aug 2011 at 11:23