Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Answer

Post Timeline

Second iteration.
Source Link
Peter Mortensen
  • 31.3k
  • 22
  • 110
  • 134

Use a simple Enum implementation like the following. There isn't any need for external libraries!

import platform
from enum import Enum
class OS(Enum):
 def checkPlatform(osName):
 return osName.lower()== platform.system().lower()
 MAC = checkPlatform("darwin")
 LINUX = checkPlatform("linux")
 WINDOWS = checkPlatform("windows") #I# I haven't testtested this one

Simply you can access them with the Enum value:

if OS.LINUX.value:
 print("Cool. itIt is Linux")

PS: It is Python 3.

Use a simple Enum implementation like the following. There isn't any need for external libraries!

import platform
from enum import Enum
class OS(Enum):
 def checkPlatform(osName):
 return osName.lower()== platform.system().lower()
 MAC = checkPlatform("darwin")
 LINUX = checkPlatform("linux")
 WINDOWS = checkPlatform("windows") #I haven't test this one

Simply you can access with the Enum value

if OS.LINUX.value:
 print("Cool it is Linux")

PS: It is Python 3.

Use a simple Enum implementation like the following. There isn't any need for external libraries!

import platform
from enum import Enum
class OS(Enum):
 def checkPlatform(osName):
 return osName.lower()== platform.system().lower()
 MAC = checkPlatform("darwin")
 LINUX = checkPlatform("linux")
 WINDOWS = checkPlatform("windows") # I haven't tested this one

Simply you can access them with the Enum value:

if OS.LINUX.value:
 print("Cool. It is Linux")

PS: It is Python 3.

Active reading [<https://en.wiktionary.org/wiki/libraries#Noun> <https://en.wikipedia.org/wiki/History_of_Python#Version_3>]. Expanded. More affirmative answer (this is not a forum - see e.g. <http://meta.stackexchange.com/a/92115>. It is a think tank (see <http://meta.stackoverflow.com/a/325681>).
Source Link
Peter Mortensen
  • 31.3k
  • 22
  • 110
  • 134

How aboutUse a simple Enum implementation like the following? No. There isn't any need for external libslibraries!

import platform
from enum import Enum
class OS(Enum):
 def checkPlatform(osName):
 return osName.lower()== platform.system().lower()

 MAC = checkPlatform("darwin")
 LINUX = checkPlatform("linux")
 WINDOWS = checkPlatform("windows") #I haven't test this one

Simply you can access with the Enum value

if OS.LINUX.value:
 print("Cool it is Linux")

P.SPS: It is python3Python 3.

How about a simple Enum implementation like the following? No need for external libs!

import platform
from enum import Enum
class OS(Enum):
 def checkPlatform(osName):
 return osName.lower()== platform.system().lower()

 MAC = checkPlatform("darwin")
 LINUX = checkPlatform("linux")
 WINDOWS = checkPlatform("windows") #I haven't test this one

Simply you can access with Enum value

if OS.LINUX.value:
 print("Cool it is Linux")

P.S It is python3

Use a simple Enum implementation like the following. There isn't any need for external libraries!

import platform
from enum import Enum
class OS(Enum):
 def checkPlatform(osName):
 return osName.lower()== platform.system().lower()
 MAC = checkPlatform("darwin")
 LINUX = checkPlatform("linux")
 WINDOWS = checkPlatform("windows") #I haven't test this one

Simply you can access with the Enum value

if OS.LINUX.value:
 print("Cool it is Linux")

PS: It is Python 3.

added 108 characters in body
Source Link
Memin
  • 4.2k
  • 1
  • 34
  • 33

How about a simple Enum implementation like the following? No need for external libs!

import osplatform
from enum import Enum
class OS(Enum):
 MACdef =checkPlatform(osName):
 "darwin" return osName.lower()== osplatform.namesystem().lower() 
 LINUXMAC = "posix".lowercheckPlatform("darwin")== os.name.lower LINUX = checkPlatform("linux")
 WINDOWS = "windows".lowercheckPlatform("windows")== os.name.lower() #I haven't test this one

Simply you can access with Enum value

if OS.LINUX.value:
 print("Cool it is Linux")

P.S It is python3

How about a simple Enum implementation like the following? No need for external libs!

import os
from enum import Enum
class OS(Enum):
 MAC = "darwin".lower()== os.name.lower() 
 LINUX = "posix".lower()== os.name.lower()
 WINDOWS = "windows".lower()== os.name.lower()

Simply you can access with Enum value

if OS.LINUX.value:
 print("Cool it is Linux")

P.S It is python3

How about a simple Enum implementation like the following? No need for external libs!

import platform
from enum import Enum
class OS(Enum):
 def checkPlatform(osName):
  return osName.lower()== platform.system().lower() 
 MAC = checkPlatform("darwin")  LINUX = checkPlatform("linux")
 WINDOWS = checkPlatform("windows")  #I haven't test this one

Simply you can access with Enum value

if OS.LINUX.value:
 print("Cool it is Linux")

P.S It is python3

Source Link
Memin
  • 4.2k
  • 1
  • 34
  • 33
Loading
lang-py

AltStyle によって変換されたページ (->オリジナル) /