[IronPython] What is a good way to determine OS platform with IronPython?

Douglas Blank dblank at brynmawr.edu
Mon Jan 10 23:37:18 CET 2011

Now that IronPython runs on other operating systems, what is the recommended way to determine the os when running IP?

sys.platform returns 'cli' across all, and sys.builtin_module_names includes 'nt' on all.

Perhaps something like:

def platform():
    data = sys.getwindowsversion() # major, minor, build, platform, service_pack
    if data.platform in [0, 1, 2, 3] return "win"
    elif data.platform == 4: return "linux"

"cli" isn't really the platform; it is the type of Python. Perhaps this should be fixed as we go forward.


More information about the Ironpython-users mailing list