Answer the question
In order to leave comments, you need to log in
How to create an optional data type in python?
In StandartML, it was possible to organize your own data type, where you could outline the possible options . The
datatype colour = red | blue | green
question is whether it is possible (and whether it is generally advisable) to write something similar in python?
That is, should there be a data type (class) that can have only a few values?
Ideally, I would like to see something like this:
color1 = Color(RED)
orcolor1 = Color(s)(Сolors.RED)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question