Alex Rivera | Logout

Can python detect which OS is it running under?

Asked 2011-01-17T23:34:38.820
10

Can python detect OS and then contruct a if/else statement for File System.

I would need to replace C:\CobaltRCX\ in Fn string with the FileSys string.

import os.path, csv
from time import strftime

if os.path.?????:## Windows
   FileSys = r"C:\\working\\" 
else:   ##linux   
   FileSys = r"\\working\\" 

y=(strftime("%y%m%d"))
Fn = (r"C:\\working\\Setup%s.csv" %y)
Edit
Report

1 Answer

0

You could look at os.uname

In [12]: os.uname()
Out[12]: 
('Darwin',
 'demitasse.local',
 '10.6.0',
 'Darwin Kernel Version 10.6.0: Wed Nov 10 18:13:17 PST 2010; root:xnu-1504.9.26~3/RELEASE_I386',
 'i386')
answered 2011-01-17T23:39:48.113

Your Answer