I want to convert a head file which is written in C to a class in python
Basically, the format of the head file in C (a file called header.c is like following:
#define ATTR_A (HELLO +1L) /*FSDSDF*/
#define ATTR_B (HELLO +2L) /*FSFSSF*/
What I want to do is writing a simple script which can read the text from header.c and then convert the format to a python calss and stored the result to a file called header.py. After conversion, it will be:
ATTR_A = (HELLO +1L)
ATTR_B = (HELLO +2L)
I know how to read the file and how to store the converted result into header.py, but I know how to do the conversion. Can someone please help me? Thanks!
regular expressionshere. Here is a nice tutorial. This is just one of the possible way to solve your problem.