23.03.2021 20:22, Paolo Bonzini wrote:
On 23/03/21 18:11, Vladimir Sementsov-Ogievskiy wrote:
If you have positional arguments that must begin with - and don’t look like 
negative numbers, you can insert the pseudo-argument '--' which tells 
parse_args() that everything after that is a positional argument:

So, as I understand argparse supports '--' feature out of the box. So, we can 
keep '*' as is, and it would parse all remaining positional arguments which are 
either tests or the command, and '--' will be automatically dropped. So, we 
only need to check existing of '--' in original sys.argv to chose our behavior.

There is still a difference with REMAINDER:

./check aa -- bb
=> REMAINDER: error because ./-- is not a test
=> look for '--':  invoke "aa -- bb"

So I think REMAINDER provides the best behavior overall.


Ok, with '*' you need to check that exactly sys.argv[-len(agrs.tests)-1] == 
'--', which gives the same behavior as REMAINDER.

I'm OK with REMAINDER too, still with we probably also need some comment to not 
embarrass next person who go into documentation and not find it.


--
Best regards,
Vladimir

Reply via email to