[Tutor] need help with syntax

bill nieuwendorp slow67 at gmail.com
Wed Jan 11 04:48:06 CET 2006


Hi John thanks for the tips

I had a bit of a typo in my first post

time = struct.unpack(">steps",c)

should read somthing more like

 time = struct.unpack(">steps+f",c)
adding the f to tell structs it is in float format

the string substitution
seems like it would work but now I cant figure out how I would add the
f on the end

also this still requires me to reassign 6 to steps

isnt this already done here ?

>>> s = L[:4]
>>> s
('\x00', '\x00', '\x00', '\x06')
>>> a = string.join( s , '')
>>> steps = struct.unpack (">l" , a)
>>> steps
(6,)


what I would like to do in the end is take the format formula.

steps = int 4
value = int 4
time = float 4 * steps

and have a python script that will spit out the ascii contents,
without me having to assign 6 to steps as that number will change from
file to file.


More information about the Tutor mailing list