pypreprocessor icon indicating copy to clipboard operation
pypreprocessor copied to clipboard

Across multiple files

Open kyuhyoung opened this issue 3 years ago • 0 comments

Hello. I tested pypreprocessor as following

In "py2and3.py"

import sys
from pypreprocessor import pypreprocessor
#exclude
if sys.version[:3].split('.')[0] == '2':
    pypreprocessor.defines.append('python2')
if sys.version[:3].split('.')[0] == '3':
    pypreprocessor.defines.append('python3')
pypreprocessor.parse()
#endexclude
from print_python_version import print_python_version
print_python_version()

In "print_python_version.py"

def print_python_version():
#ifdef python2
    print('You are using Python 2x')
#else
#ifdef python3
    print('You are using python 3x')
#else
    print('Python version not supported')
#endifall

And the output of "python py2and3.py" is :

You are using Python 2x
You are using python 3x
Python version not supported

which means things such as #ifdef and #else are NOT effective in the file "print_python_version.py" anymore. How can I make the macro effective all over the files in the project ?

kyuhyoung avatar Jan 27 '22 02:01 kyuhyoung