Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Unpacking a list of strings

Reply
Thread Tools

Unpacking a list of strings

 
 
Panos Laganakos
Guest
Posts: n/a
 
      04-27-2006
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])?

 
Reply With Quote
 
 
 
 
Alex Martelli
Guest
Posts: n/a
 
      04-27-2006
Panos Laganakos <> wrote:

> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
unpacking vars from list of tuples Ross Python 15 09-22-2009 10:21 PM
tricky nested list unpacking problem Reckoner Python 7 12-16-2008 05:18 PM
Unpacking byte strings from a file of unknown size Mark Python 5 10-29-2008 05:14 AM
Strings, Strings and Damned Strings Ben C Programming 14 06-24-2006 05:09 AM
convert list of strings to set of regexes; convert list of strings to trie Klaus Neuner Python 7 07-26-2004 07:25 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57