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
'nt' means 'New Technology' which is come with the release of a 32-bit version initially.
The Python window is an efficient and convenient location to use geoprocessing tools and Python functionality from within ArcGIS. The Python commands run from this window can range from single lines of code to complex blocks with logic.
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.
The solution used in Twisted, which doesn't need pywin32:
def isVista(): if getattr(sys, "getwindowsversion", None) is not None: return sys.getwindowsversion()[0] == 6 else: return False
Note that it will also match Windows Server 2008.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With