How to pretty-print ctypes composite data types?

Discussion in 'Python' started by Grant Edwards, Oct 25, 2011.

  1. I'm using ctypes with a library that requires a handful of structure
    definitions. The actual definitions and usage aren't a problem. When
    it comes time to print out the values in a structure or array, there
    doesn't seem to be simple/general way to do that. Am I missing
    something?

    I presume one can recursively iterate through the fields in a
    structure and elements in an array, recursing on any composite types
    and printing the values when one finds a type, but I'm surprised
    that's not something that's already in the ctypes library somewhere --
    the authors certainly seem to have thought of everything else.

    --
    Grant Edwards grant.b.edwards Yow! I own seven-eighths of
    at all the artists in downtown
    gmail.com Burbank!
     
    Grant Edwards, Oct 25, 2011
    #1
    1. Advertisements

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. Andrew Montgomery
    Replies:
    0
    Views:
    824
    Andrew Montgomery
    Sep 17, 2003
  2. ramu
    Replies:
    2
    Views:
    533
    rlblaster
    Feb 20, 2006
  3. keto
    Replies:
    0
    Views:
    1,343
  4. Replies:
    0
    Views:
    668
  5. Robert Dailey

    'pretty print' for built in types

    Robert Dailey, Dec 9, 2008, in forum: Python
    Replies:
    3
    Views:
    353
    Chris Rebert
    Dec 9, 2008
  6. David Cournapeau

    print a vs print '%s' % a vs print '%f' a

    David Cournapeau, Dec 30, 2008, in forum: Python
    Replies:
    0
    Views:
    615
    David Cournapeau
    Dec 30, 2008
  7. Sam
    Replies:
    2
    Views:
    1,032
    Diez B. Roggisch
    Oct 17, 2009
  8. Gary Roach
    Replies:
    0
    Views:
    222
    Gary Roach
    Sep 1, 2013
Loading...