Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

Tell difference between Windows/Mac/Linux in Python script

  • 30-10-2009 11:27AM
    #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,922 ✭✭✭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