◐ Shell
clean mode source ↗

Message 229990 - Python tracker

Ned Deily: I don't quite know how to use unittest, but I'll try to look into it.

paul j3:
> There I proposed leaving '_negative_number_matcher' unchanged, 
> but only use it to set '_has_negative_number_optionals'.

I don't know argparse internals but, if I understand your argument, I think you still need a '_negative_number_matcher' capable of correctly match any negative number in any form, including scientific notation, complex j, etc..
If this is the case, then, the matcher could be simplified to something like

    '^-\d+|^-.\d+'

(notice $ removed from current regex) which would only signal that "something that starts like a negative number" is present.
Then one could use complex() or float() or whatever, to check that that's actually the case.

I would still expect an exception to be raised if, say, I specify type=float and then a complex value is passed as an argument.