I had namedtuple variable which represents version of application (its number and type). But i want and some restriction to values:
Version = namedtuple("Version", ["app_type", "number"])
version = Version("desktop") # i want only "desktop" and "web" are valid app types
version = Version("deskpop") # i want to protect from such mistakes
My solution for now is primitive class with no methods:
class Version:
def __init__(self, app_type, number):
assert app_type in ('desktop', 'web')
self.app_type = app_type
self.number = number
Is it pythonic? Is it overkill?