How to check if OS is unix or pc

Discussion in 'Python' started by bahoo, Apr 3, 2007.

  1. bahoo

    bahoo Guest

    In Matlab, there is a "isunix" command.
    Is there something similar in python?

    Thanks!
    bahoo
    bahoo, Apr 3, 2007
    #1
    1. Advertising

  2. bahoo

    Guest

    On Apr 3, 4:12 pm, "bahoo" <> wrote:
    > In Matlab, there is a "isunix" command.
    > Is there something similar in python?
    >
    > Thanks!
    > bahoo


    Check out the platform module. It should do what you need. The
    "release()" method is especially useful.

    Mike
    , Apr 3, 2007
    #2
    1. Advertising

  3. bahoo a écrit :
    > In Matlab, there is a "isunix" command.
    > Is there something similar in python?


    >>> import os
    >>> os.uname()

    ('Linux', 'bibi', '2.6.9', '#1 Sun Dec 5 14:54:12 CET 2004', 'i686')
    >>> os.name

    'posix'
    >>> isunix = lambda: os.name == 'posix'
    >>> isunix()

    True

    Note that if you worry about system-specific path separators, there's
    the os.path module.
    Bruno Desthuilliers, Apr 3, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    12
    Views:
    1,635
    Dave Thompson
    Jan 10, 2005
  2. GujuBoy

    Win32 or Unix check in python

    GujuBoy, Mar 29, 2005, in forum: Python
    Replies:
    1
    Views:
    338
    Erik Max Francis
    Mar 29, 2005
  3. Replies:
    4
    Views:
    1,199
    Fredrik Lundh
    Nov 2, 2005
  4. Replies:
    18
    Views:
    618
    Dave Thompson
    Jan 10, 2005
  5. Robert Wallace

    my own perl "dos->unix"/"unix->dos"

    Robert Wallace, Jan 21, 2004, in forum: Perl Misc
    Replies:
    7
    Views:
    276
    Michele Dondi
    Jan 22, 2004
Loading...

Share This Page