Unpacking a list of strings

P

Panos Laganakos

Is there some other practice than reading all the strings and slicing
them later?

They're stored in the form of:
List Group[10]:
char[17] name;

So I thought of doing:
unpacked = unpack('%s' % (10*17), data)

And then slicing the list by a step of 17.

Is there some way to have unpack return a tuple with each element
holding the name (char[17])?
 
A

Alex Martelli

Panos Laganakos said:
Is there some other practice than reading all the strings and slicing
them later?

They're stored in the form of:
List Group[10]:
char[17] name;

So I thought of doing:
unpacked = unpack('%s' % (10*17), data)

And then slicing the list by a step of 17.

Is there some way to have unpack return a tuple with each element
holding the name (char[17])?

unpack by formatstring 10*'17s' ...


Alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top