[Tutor] Concatenating numeric data in Python 3.3

Alan Gauld alan.gauld at btinternet.com
Wed Apr 24 21:12:49 CEST 2013


On 24/04/13 17:52, sparkle Plenty wrote:
> What is the best way to concatenate packed numeric data?

There are lots of options but one way to produce a byte string from 
(semi) arbitrary  values is to use the struct module.
It uses a format string to define the data format and lengths and then 
substitutes in the values it is given to 'pack'.

PS.
Its a bit like a PICT string in COBOL if your that kind
of mainframer!

If that doesn't help then we will need a bit more detail of the kind of 
thing you want. Even a made up example with just a couple of fields...

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list