git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Like c enumeration in python3



> On 23 Mar 2020, at 11:52, Rhodri James <rhodri at kynesim.co.uk> wrote:
> 
> On 23/03/2020 02:18, Paulo da Silva wrote:
>> Hi!
>> Suppose a class C.
>> I want something like this:
>> class C:
>> 	KA=0
>> 	KB=1
>> 	KC=1
>> 	...
>> 	Kn=n
>> 	def __init__ ...
>> 		...
>> These constants come from an enum in a .h (header of C file).
>> They are many and may change from time to time.
>> Is there a way to somehow define them from inside __init__ giving for
>> example a list of names as strings?
> 
> It sounds like what you want is a separate script to process your .h file into a Python module containing an enum, then import that module into your program.

web search for "python parse C header" yields some interesting results.

Barry


> 
> -- 
> Rhodri James *-* Kynesim Ltd
> -- 
> https://mail.python.org/mailman/listinfo/python-list <https://mail.python.org/mailman/listinfo/python-list>