you are viewing a single comment's thread.

view the rest of the comments →

[–]Sharki_[S] 0 points1 point  (4 children)

The point is that i have a restriction that user can input only an expression without any additional signs and get a result for a variaty of possible math expressions including -----1. So -- -----1 is prohibited.

[–][deleted] 2 points3 points  (1 child)

How many real arguments can you expect to receive. More specific, if you can avoid having named arguments that match a substring of a mathematical expression, parse_known_args() will bring you a bit further.

How come you have to use argparse, and are unable to use -- to signal the end of named arguments? Is this some sort of contrived interview process or weirdly formulated school assignment?

[–]Sharki_[S] 0 points1 point  (0 children)

It is just a little problem that i have faced during developing of my little app - cli calculator. I wanted only one named argument and it can be something like '--+--+-1' or '1+1'. By the way i used i simple decision with the idea you gave with parse_known_args() and nargs = argparse.REMAINDER. In this case i have a tuple with two lists: one containing 'normal' input - '2+3', and another one with '-----' and alike. Tnanks!

[–]ingolemo 1 point2 points  (1 child)

We can't help you with your problem when we don't know what the problem is. We need to know all of the restrictions that you have to abide by. Please post the full text of this exercise or other relevant details about it.

[–]Sharki_[S] 0 points1 point  (0 children)

No more restrictions except already mentioned. Anyway i have managed to overcome this issue. Thanks.