开发者

python ctypes arrays

I would like to have an array of variable length arrays in ctypes. I know the size of the outer array and all of the inner arrays, too.

I found a开发者_如何学运维n interesting thread here: How do I emulate a dynamically sized C structure in Python using ctypes

But the problem with this is how to create an array of Var classes (see the comment How do I emulate a dynamically sized C structure in Python using ctypes )

Maybe it's something that i cannot do with ctypes at all, i don't really know, i'm getting to know the module only for some hours, any pointers are appreciated.

Thank you!


Dynamically sized data structures are handled in ctypes the same way they are in C; you use pointers to dynamic data. Unfortunately, there's no shortcut on this one. The ctypes documentation includes fairly detailed descriptions on how to handle pointers to dynamic data (such as using a pointer as an arbitrarily sized array). It can be a little hard to grasp at first though. Personally, I've found that creating a few small test applications is helpful in verifing my use of ctypes and dynamic data. It may take some time and a little head-scratching but the interface is pretty flexible so I would expect that you'll be able to accomplish your goal using ctypes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜