Skip to main content
added 233 characters in body
Source Link
Evan Plaice
  • 14.2k
  • 6
  • 78
  • 95

Use pypreprocessor

Which can also be found on PYPI (Python Package Index) and can be fetched using pip.

The basic example of usage is:

from pypreprocessor import pypreprocessor

pypreprocessor.parse()

#define debug

#ifdef debug
print('The source is in debug mode')
#else
print('The source is not in debug mode')
#endif

You can also output the postprocessed code to a file by specifying...

pypreprocessor.output = 'output_file_name.py'

anywhere between the pypreprocessor import and the call to parse().

The module is essentially the python implementation of C preprocessor conditional compilation.

SideNote: This is compatible with both python2x and python 3k

Disclaimer: I'm the author of pypreprocessor

Update:

I forgot to mention before. Unlike the if/else or if _debug: approaches described in other answers, this is a true preprocessor. The bytecode produced will not contain the code that is conditionally excluded.

Use pypreprocessor

Which can also be found on PYPI (Python Package Index) and can be fetched using pip.

The basic example of usage is:

from pypreprocessor import pypreprocessor

pypreprocessor.parse()

#define debug

#ifdef debug
print('The source is in debug mode')
#else
print('The source is not in debug mode')
#endif

You can also output the postprocessed code to a file by specifying...

pypreprocessor.output = 'output_file_name.py'

anywhere between the pypreprocessor import and the call to parse().

The module is essentially the python implementation of C preprocessor conditional compilation.

SideNote: This is compatible with both python2x and python 3k

Disclaimer: I'm the author of pypreprocessor

Use pypreprocessor

Which can also be found on PYPI (Python Package Index) and can be fetched using pip.

The basic example of usage is:

from pypreprocessor import pypreprocessor

pypreprocessor.parse()

#define debug

#ifdef debug
print('The source is in debug mode')
#else
print('The source is not in debug mode')
#endif

You can also output the postprocessed code to a file by specifying...

pypreprocessor.output = 'output_file_name.py'

anywhere between the pypreprocessor import and the call to parse().

The module is essentially the python implementation of C preprocessor conditional compilation.

SideNote: This is compatible with both python2x and python 3k

Disclaimer: I'm the author of pypreprocessor

Update:

I forgot to mention before. Unlike the if/else or if _debug: approaches described in other answers, this is a true preprocessor. The bytecode produced will not contain the code that is conditionally excluded.

added 4 characters in body
Source Link
Evan Plaice
  • 14.2k
  • 6
  • 78
  • 95

Use pypreprocessorpypreprocessor

Which can also be found on PYPI (Python Package Index) and can be fetched using pip.

The basic example of usage is:

from pypreprocessor import pypreprocessor

pypreprocessor.parse()

#define debug

#ifdef debug
print('The source is in debug mode')
#else
print('The source is not in debug mode')
#endif

You can also output the postprocessed code to a file by specifying...

pypreprocessor.output = 'output_file_name.py'

anywhere between the pypreprocessor import and the call to parse().

The module is essentially the python implementation of C preprocessor conditional compilation.

SideNote: This is compatible with both python2x and python 3k

Disclaimer: I'm the author of pypreprocessor

Use pypreprocessor

Which can also be found on PYPI (Python Package Index) and can be fetched using pip.

The basic example of usage is:

from pypreprocessor import pypreprocessor

pypreprocessor.parse()

#define debug

#ifdef debug
print('The source is in debug mode')
#else
print('The source is not in debug mode')
#endif

You can also output the postprocessed code to a file by specifying...

pypreprocessor.output = 'output_file_name.py'

anywhere between the pypreprocessor import and the call to parse().

The module is essentially the python implementation of C preprocessor conditional compilation.

SideNote: This is compatible with both python2x and python 3k

Disclaimer: I'm the author of pypreprocessor

Use pypreprocessor

Which can also be found on PYPI (Python Package Index) and can be fetched using pip.

The basic example of usage is:

from pypreprocessor import pypreprocessor

pypreprocessor.parse()

#define debug

#ifdef debug
print('The source is in debug mode')
#else
print('The source is not in debug mode')
#endif

You can also output the postprocessed code to a file by specifying...

pypreprocessor.output = 'output_file_name.py'

anywhere between the pypreprocessor import and the call to parse().

The module is essentially the python implementation of C preprocessor conditional compilation.

SideNote: This is compatible with both python2x and python 3k

Disclaimer: I'm the author of pypreprocessor

Source Link
Evan Plaice
  • 14.2k
  • 6
  • 78
  • 95

Use pypreprocessor

Which can also be found on PYPI (Python Package Index) and can be fetched using pip.

The basic example of usage is:

from pypreprocessor import pypreprocessor

pypreprocessor.parse()

#define debug

#ifdef debug
print('The source is in debug mode')
#else
print('The source is not in debug mode')
#endif

You can also output the postprocessed code to a file by specifying...

pypreprocessor.output = 'output_file_name.py'

anywhere between the pypreprocessor import and the call to parse().

The module is essentially the python implementation of C preprocessor conditional compilation.

SideNote: This is compatible with both python2x and python 3k

Disclaimer: I'm the author of pypreprocessor