Getting the literal out of a python Literal type, at runtime?
The typing module provides a function get_args which retrieves the arguments with which your Literal was initialized. >>> from typing import Literal, get_args >>> l = Literal[‘add’, ‘mul’] >>> get_args(l) (‘add’, ‘mul’) However, I don’t think you gain anything by using a Literal for what you propose.