Iterable Ctypes Struct

mark.seagoe at gmail.com mark.seagoe at gmail.com
Wed Feb 11 03:31:26 CET 2009


I like the ability to access elements of a struct such as with ctypes
Structure:
>>>myStruct.elementName1
4

What I like about it is there are no quotes needed.

What I don't like about it is that it's not iterable:
>>>for n in myStruct:  <== gives error
>>>    print n

I don't want to force the end user to have preknowledge of the element
names.
Has anyone subclassed ctypes Structure based class to be iterable?
Before a noob starts trying to do this, is it possible?  How to
approach it?

Thx,
Mark



More information about the Python-list mailing list