The usual test for distinguishing between running a Python application on Windows and other operating systems (usually Linux) is to use a conditional:
if sys.platform == 'win32': ...
But I wonder if it can be used today when 64-bit Python has been more widely used in recent years? Does 32 really mean 32-bit, or is it mainly related to the Win32 API?
If it is possible to have sys.platform one day as "win64", perhaps such a condition would be more universal?
if sys.platform.startswith('win'): ...
There is also another way to discover Windows that I know of:
if os.name == 'nt': ...
But I really never saw the use of the latter in other code.
What is the best way?
UPD . I would like to avoid using additional libraries if possible. The requirement to install an additional library to verify that I am not working on Windows can annoy Linux users.
python windows cross-platform 64bit 32bit-64bit
bialix Jan 27 '10 at 5:21 2010-01-27 05:21
source share