How to find out operating system

Fredrik Lundh fredrik at pythonware.com
Thu Jun 27 12:50:32 EDT 2002


"A" wrote:

> What is the best way of  finding out the kind operating system?
> I can use os.name but if the system is Windows I would like also
> know if the system is Windows98 or Windows ME or W2K or
> Windows XP.

some variation of

    import os
    if os.name == "nt":
        version = os.popen("ver").read()
        if version.find("Windows 2000") >= 0:
            ... windows 2000
        elif ...
        ...
    else:
        version = os.uname()
        version = version[0], version[1]
        ...

might do the trick.

or use the PythonWin extensions (see lawrence's post)

</F>





More information about the Python-list mailing list