Hello
I am finding it difficult to pass arguments to struct.pack().
Please some one tell me how to do it.
>>> def structpack(alist):
import struct
a='%di'%len(alist)
print a
b=[a]
print alist
print b
for x in alist:
b.append(x)
arg1=b[0]
arg2=b[1:]
return struct.pack.tuple(arg1,arg2)
>>> structpack([112, 114, 97, 115, 97, 100, 97, 32, 114, 97, 111, 32, 110])
13i
[112, 114, 97, 115, 97, 100, 97, 32, 114, 97, 111, 32, 110]
['13i']
Traceback (most recent call last):
File "<pyshell#87>", line 1, in <module>
pstruct([112, 114, 97, 115, 97, 100, 97, 32, 114, 97, 111, 32, 110])
File "<pyshell#86>", line 16, in pstruct
return struct.pack.tuple(b)
AttributeError: 'builtin_function_or_method' object has no attribute 'tuple'
>>>
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor