Skip to content

Across multiple files #33

@kyuhyoung

Description

@kyuhyoung

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 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions