Converting C++ array into Python

Jorgen Grahn jgrahn-nntq at algonet.se
Wed Oct 12 13:43:18 EDT 2005


On Wed, 12 Oct 2005 11:13:52 -0500, Larry Bates <larry.bates at websafe.com> wrote:
> Like others, without more information on what you have tried we are
> just guessing.  Many times I've used the struct.unpack() module to
> unpack C "arrays" into python objects.

In that case, it sounds like you make yourself depend on the memory layout
of those C arrays -- generally a very bad thing to do.

> Don't know if this will help,
> but thought I'd pass it along.  Post some code and we can help more.

Yes. Or at least tell us what the /type/ of that array is.

I assume it's 'Foo thearray[]', in which case you usually would return it as
a Python list of whatever Python data structure you encode a Foo into --
might be a tuple, or an integer, or a full-blown class of some kind, or ...

/Jorgen

-- 
  // Jorgen Grahn <jgrahn@       Ph'nglui mglw'nafh Cthulhu
\X/                algonet.se>   R'lyeh wgah'nagl fhtagn!



More information about the Python-list mailing list