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.
- 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.
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