Conversion of perl unpack code to python - something odd
Peter Otten
__peter__ at web.de
Thu May 18 09:52:30 EDT 2006
Andrew Robert wrote:
> format='4s 4s 48s 48s 64s 4s 256s 128s 128s 48s'
You are trying to squeeze 10 items into just
> d1,d2=struct.unpack(format,data)
two variables (d1 and d2)
> ValueError: too many values to unpack
and Python is quite explicit that it doesn't like that once you realize that
'unpack' doesn't refer to struct.unpack() but to tuple unpacking like
>>> a, b = "ab"
>>> a, b = "abc"
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ValueError: too many values to unpack
Peter
More information about the Python-list
mailing list