How to check if OS is unix or pc

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Tue Apr 3 17:59:36 EDT 2007


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.



More information about the Python-list mailing list