As the title says how can I find the current OS in python?
http://python.org/doc/2.5/lib/module-os.html
To compliment Greg's post, if you're on a posix system, which includes MacOS, Linux, Unix, etc. you can use os.uname() to get a better feel for what kind of system it is.
import os
print os.name
This gives you the essential information you will usually need. To distinguish between, say, different editions of Windows, you will have to use a platform-specific method.
I usually use sys.platform
to get the platform. sys.platform
will distinguish between linux, other unixes, and OS X while os.name
is "posix
" for all of them.
For much more detailed information, use the platform module. This has cross-platform functions that will give you information on the machine architecture, OS and OS version, version of Python, etc. Also it has os-specific functions to get things like the particular linux distribution.