Python: get windows OS version and architecture
- by Thorfin
First of all, I don't think this question is a duplicate of
http://stackoverflow.com/questions/2208828/detect-64bit-os-windows-in-python
because imho it has not been thoroughly answered.
The only approaching answer is:
Use sys.getwindowsversion() or the existence of PROGRAMFILES(X86) (if 'PROGRAMFILES(X86)' in os.environ)
But:
Can we completely rely on the windows environment variable PROGRAMFILES(X86)? I fear that anyone can create it, even if it's not present on the system.
How can we use sys.getwindowsversion() to get the architecture?
Regarding sys.getwindowsversion():
The link http://docs.python.org/library/sys.html#sys.getwindowsversion
leads us to http://msdn.microsoft.com/en-us/library/ms724451%28VS.85%29.aspx
but I don't see anything related to the architecture (32bit/64bit).
Moreover, the platform element if the returned tuple seems to be independent of the architecture.
One last note, I'm using python 2.5.
Thanks!