I have a simple piece of Python code, I have a number of enums defined like this:
import sys
from time import sleep
from enum import Enum
class BW(Enum):
LTE1p4 = 0
LTE3 = 1
LTE5 = 2
LTE10 = 3
LTE15 = 4
LTE20 = 5
I want member functions of a class to only accept this Enum type as an argument and the script should not run otherwise, here is my main class:
class Breithorn:
def __init__(self):
self.RX_Settings = {}
self.TX_Settings = {}
def RX_BW(self,BW):
self.RX_Settings['BW'] = BW
I want the member function to only accept these kind of calls:
Breithorn.RX_BW(BW.LTE5)
And reject (syntax error) these kind of calls:
Breithorn.RX_BW(44)
Can someone explain how to do this?