I'm interested to escape a string in Python3.x, such as:
SOME_MACRO(a, b)
into...
SOME_MACRO\(a,\ b\)
... so that it can be passed to a program (not gcc in this case) as a define,
eg,
some_program -DSOME_MACRO\(a,\ b\)="some expression"
I would expect shlex
would have this functionality but I didn't find how to do this and checked many similar questions already.
I don't mind to write some simple function to do this, but this seems the kind of thing Python would include.
Note: the program I'm passing the argument to wont accept:
-D"SOME_MACRO(a, b)"="some expression"
... it expects the first character to be an identifier.