Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

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