João P 2018
João P 2018

Reputation: 7

cant use optparse saved parameters because it is <value> type (PYTHON)

The parameters a user gives to the code is "inputs" variable

inputs,args=parser.parse_args()

However, when I try to apply a regex in it (I want the user to digit valid parameters for a option), I cant because when I try something like

re.match(r"((\w{2}[^\w]){5}\w{2})",inputs["Dictionary_Key"])

Python fails because "regex expects a strings or bytes object", but parse_args() returns a <opt.Values> data type How can I convert ? I've tried

option_dict = vars(inputs)

and

str(inputs)

but neither resolved my problem

Upvotes: 0

Views: 36

Answers (0)

Related Questions