Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Good news everyone! The Boards.ie Subscription service is live. See here: https://subscriptions.boards.ie/

Tell difference between Windows/Mac/Linux in Python script

  • 30-10-2009 12:27PM
    #1
    Hosted Moderators Posts: 7,486 ✭✭✭


    I have a python script that's just replacing a shell script. I'd like it to run slightly differently depending on whether it's invoked on a Windows, Mac or Linux machine. Does anyone know how to do this, maybe with the OS library - but I didn't find anything when I looked.

    Thanks!


Comments

  • Registered Users, Registered Users 2 Posts: 1,919 ✭✭✭ronivek


    You can try the platform module.

    As far as I know however it will still require a knowledge of the possible values that may be returned on your target Operating Systems.


  • Registered Users, Registered Users 2 Posts: 5,112 ✭✭✭Blowfish


    import sys
    print sys.platform
    
    :)


  • Hosted Moderators Posts: 7,486 ✭✭✭Red Alert


    Thanks very much!


Advertisement