Python Forum
version/compile info - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: version/compile info (/thread-10119.html)

Pages: 1 2


RE: version/compile info - ljmetzger - May-19-2018

Python 2:
Output:
>>> import sys >>> sys.platform 'linux2' >>>
Python 3:
Output:
>>> import sys >>> sys.platform 'linux' >>>
It's not a bug, it's a 'feature'. The '3' was removed in Python 3.3

See https://bugs.python.org/issue12326 for a long winded 'official' discussion.

For a summary see: https://stackoverflow.com/questions/10415942/python-sys-platform-linux2-but-not-linux3

In the summary link it is suggested to use one of:
sys.platform.startswith('linux')

sys.platform == 'linux' # if you don't need to support older Python versions

It is also mentioned that 'win32' is used on all Windows systems, as apparently the term 'Win64' offends Microsoft.

Lewis


RE: version/compile info - Skaperen - May-20-2018

so it really was (not is, anymore) the Linux version. you know they could have done:
  if 'linux' in sys.platform: # Is it any version of Linux?
so does the "win32" platform have any 64-bit capability? maybe i'll just keep on offending Microsoft by saying "they don't even have a 64-bit API, yet, and are still doing 'win32'". or people need to do:
  if 'win' in sys.platform:
        raise TypeError('Bad platform type == you lose')