Conditional Compilation for bytecode?
Dirk-Ulrich Heise
hei at adtranzsig.de
Thu Jun 22 05:00:05 EDT 2000
> I have some code that needs to run on Win32 and IRIX.
>
> I thought I read somewhere that python had a sort of conditional
> compilation that would generate different .pyc files depending on the
> directives in the .py file.
>
> i.e.
> #ifdef WIN32
> CreateProcess(...)
> #else UNIX
> fork()
> #endif
>
How about
if sys.platform = 'Win32':
def fun():
CreateProcess(...)
else:
def fun():
fork()
fun()
? When importing this, Python will create a function that doesn't check at
runtime.
Dipl.Inform. Dirk-Ulrich Heise
hei at adtranzsig.de
dheise at debitel.net
More information about the Python-list
mailing list