How to check if OS is Vista in Python?

DzinX picture DzinX · Oct 13, 2008 · Viewed 16.7k times · Source

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

Answer

monkut picture monkut · Oct 14, 2008

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.