[英]match.arg equivalent in Python?
Is there an equivalent in Python to match.arg() as you have in R? Python 中是否有与 R 中相同的 match.arg() ? Basically limiting the user the choice of inputs one can make for an input function parameter.
基本上限制了用户对输入 function 参数的选择。
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.氪。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.