0

I use Python shell under Ubuntu 13.10. My Linux Kernel version is "3.11.0-13-generic". So why in Python variable "sys.platform" stored value "Linux2" instead of "Linux3"?

enter image description here

eterey
  • 390
  • 1
  • 4
  • 16

3 Answers3

3

From the docs:

Changed in version 2.7.3: Since lots of code check for sys.platform == 'linux2', and there is no essential change between Linux 2.x and 3.x, sys.platform is always set to 'linux2', even on Linux 3.x.

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
2

According to the documentation:

sys.platform is always set to 'linux2', even on Linux 3.x. In Python 3.3 and later, the value will always be set to 'linux', so it is recommended to always use the startswith idiom presented above.

Andy
  • 49,085
  • 60
  • 166
  • 233
1

Because sys.platform isn't a kernel version. It's a string added to the python binary or library when it's compiled. It's always linux2 on linux except after Python 3.3 when it changed to just linux.

Possible values from sys.platform?

Community
  • 1
  • 1
SpliFF
  • 38,186
  • 16
  • 91
  • 120