I am writing a rather large application, which will be compiled using py2exe. One issue I have come into is that for testing purposes my code has a lot of print statements in it, which I don't want inside the main "final" application. To fix this I simply routed all sys.stdout into a black hole, and it works fine. However this got me thinking about a feature that could be added into py2exe - some kind of global compile-time variables that can be queried at runtime.
For example to switch between my debug and "final" builds I flick a boolean object from True to False, then run my setup.py. Is it possible to give py2exe a dictionary of keys and values that gets hardcoded into the completed binary (Maybe in the bootstrap somewhere, or in a extra module that gets included automatically), so I can have one codebase and simply change the setup.py values.

Example:
----------------------------------------------
import py2exevars
if not py2exevars.get("debug"):
   sys.stdout = blackHole()
----------------------------------------------

The value of "debug" is set in the setup.py file, so you can alter code flow by changing the setup.py rather than the actual code itself.