Search code examples
pythonwindowswindows-vistawxpythonpywin32

How to check if OS is Vista in Python?


How, in the simplest possible way, distinguish between Windows XP and Windows Vista, using Python and pywin32 or wxPython?

Essentially, I need a function that called will return True iff current OS is Vista:

>>> isWindowsVista()
True

Solution

  • Python has the lovely 'platform' module to help you out.

    >>> import platform
    >>> platform.win32_ver()
    ('XP', '5.1.2600', 'SP2', 'Multiprocessor Free')
    >>> platform.system()
    'Windows'
    >>> platform.version()
    '5.1.2600'
    >>> platform.release()
    'XP'
    

    NOTE: As mentioned in the comments proper values may not be returned when using older versions of python.