> I have C header files which I parse and to which I can do some simple > processing before outputting them as Python code. An example C file > will contain > > enum { > kConstantOne = 0xffffffff, > kConstantTwo = -1, > }; > > Regexps will grab the two constants and output them to Python. The > Python programmer will pass these constants to an API routine, at which > point I need a PyArg_Parse format char that will convert both of these > values to the 32 bit pattern 0xffffffff. > > Question 1: Do I need to add anything to the constants before > outputting them as Python code? No -- kConstantTwo automatically become a long with value 2**32-1 in Python 2.3 and up. > Question 2: Is there a format char that will convert both of the values > produced by the answer to question 1 to the 32 bit pattern 0xffffffff? If you mean a PyArg_Parse format char, yes: use 'k'. If you meant a Python % format char, you'd have to write "%x" % (x&0xffffffff). --Guido van Rossum (home page: http://www.python.org/~guido/)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4