How to limit an input parameter's value range in a python way?
Advertisements If I design a function like def f(a, b): … a must be in [1,2,3]. If I pass 4 to parameter a, it should raise an exception. Is there a pythonic way to limit the value range of a function argument? Added Please note, is there a more pythonic way to implement it? Not… Read More How to limit an input parameter's value range in a python way?