...
Your .py
files will now have a series of blocks that look like this, using C preprocessor syntax:
NOTE: The sense of the "#ifdef/#ifndef" is backwards from what we really want, but this will be dealt with in a later section below. I've added annotated the lines further to make it clearer which lines are the python2 and which are the python3 code. |
|
...
You need to change blocks such as this:
|
to this. Make CERTAIN that the indentation is adjusted as well.
|
Yes, there is some cognitive dissonance for changing "#ifndef" to "if", but the rest of the generated code is set up properly to be able to quickly edit the code.
- Search for all instances of "
#ifndef USING_PYTHON2
" and change "#ifndef
" to "if
" and add a trailing ":
". - Search for all instances of "
#else /* USING_PYTHON2 */
" and change that to "else:". - Remove all instances of "
#endif /* USING_PYTHON2 */
" from the code. - Re-indent the lines in between.
You should also search for "#ifdef USING_PYTHON2" and change that to "if not USING_PYTHON2:".
Import Statements
The way that imports of functions found in local files changes in Python3. So change blocks such as this:
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...