Is there any preprocessor step available in Python?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • psbasha
    Contributor
    • Feb 2007
    • 440

    Is there any preprocessor step available in Python?

    Hi,

    I have a code written in Windows creating the spreadsheet as ouput.I need to make use of the same code in UNIX to create spreadsheet or other format.

    Is there any preprocessor step available in Python?

    Similar to C/C++

    #ifdef WIN /*Windows*/

    /*Call Windows Snippet of code*/
    #elseif UNIX-AIX
    /*Call UNIX-AIX Snippet of code*/
    #elseif
    /* Other OS Support

    Thanks
    PSB
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    Try this:
    Code:
    import os
    if os.environ["OS"] == "Windows_NT":
        # do something
    elif os.environ["OS"] == "another OS":
        # do something else
    Or this:
    Code:
    >>> import platform
    >>> platform.system()
    'Windows'
    >>>

    Comment

    Working...