Order in metaclass

Thomas Heller theller at python.net
Wed Oct 13 16:24:02 EDT 2004


Nicolas Fleury <nid_oizo at yahoo.com_remove_the_> writes:

> Thomas Heller wrote:
>> In this case, you could also look at the ctypes module, it implements C
>> compatible structures and unions.
>> And for your original question: why do you insist on your new syntax,
>> why don't you simply (as ctypes also does it) define the attributes in a
>> list, when they have to have a certain order?
>
> I just looked at ctypes, and yes, that's exactly what I'm doing.  I
> want the structures definitions to be modified by C++ programmers and
> I find the metaclass mechanism much more readable and easy to modify
> (and it's not a lot of code to make everything work).  I agree
> everything can be done using normal Python code, but my goal here is
> really to make a pseudo-language to define our formats, and the
> pseudo-language is just a simpler solution than XML in my specific
> case.  Probably all cases of such using of metaclasses are like
> that...


FWIW, I have a parser(code generator (using gccxml as frontend). This
toolchain creates ctypes' compatible structure definitions from C header
files.

Thomas



More information about the Python-list mailing list