Unpacking a list of strings

Discussion in 'Python' started by Panos Laganakos, Apr 27, 2006.

  1. 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])?
    Panos Laganakos, Apr 27, 2006
    #1
    1. Advertising

  2. 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
    Alex Martelli, Apr 27, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Klaus Neuner
    Replies:
    7
    Views:
    487
    Klaus Neuner
    Jul 26, 2004
  2. Ben

    Strings, Strings and Damned Strings

    Ben, Jun 22, 2006, in forum: C Programming
    Replies:
    14
    Views:
    756
    Malcolm
    Jun 24, 2006
  3. Mark
    Replies:
    5
    Views:
    393
  4. Reckoner
    Replies:
    7
    Views:
    330
    Steve Holden
    Dec 16, 2008
  5. Ross
    Replies:
    15
    Views:
    668
    Vlastimil Brom
    Sep 22, 2009
Loading...

Share This Page