Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

match.arg equivalent in Python?

Is there an equivalent in Python to match.arg() as you have in R? Basically limiting the user the choice of inputs one can make for an input function parameter.

like image 338
Ferhat Avatar asked Nov 07 '22 11:11

Ferhat


1 Answers

I know it is an old question, but I needed this and there is no answer. So, just for future need:

def match_arg(x, lst):
    return [el for el in lst if x in el]
    
lst = ["gaussian", "epanechnikov", "rectangular", "triangular"]
print(match_arg("gauss", lst))
print(match_arg("pauss", lst))

Which yield:

['gaussian']
[]

Kr.

like image 113
antoine Avatar answered Nov 15 '22 05:11

antoine