Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Across multiple files #33

Open
kyuhyoung opened this issue Jan 27, 2022 · 0 comments
Open

Across multiple files #33

kyuhyoung opened this issue Jan 27, 2022 · 0 comments

Comments

@kyuhyoung
Copy link

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant