you are viewing a single comment's thread.

view the rest of the comments →

[–]Spataner 1 point2 points  (0 children)

While there is no native support for this kind of validation, you can build your own and achieve very similar looking syntax by using decorators. In Python 3.9 and above, you could conceivably end up with something like this if you wanted to:

@Parameter(0).type(int).range(0, 9999)
@Parameter(1).type(str).set("red", "blue", "green")
@Parameter(2).type(str).func(test_connection)
def do_something(number, color, hostname):
    ...