On 27Jan2019 10:30, Peter Otten <[email protected]> wrote:
Cameron Simpson wrote:
Mats has mentioned the modules getopt and argparse etc. These are
primarily aimed at option parsing ("-v", "-o foo"). Your situation
occurs _after_ the option parsing (in your case, there are no options).

Not argparse. The main advantage over optparse is its handling of positional
arguments.

I stand corrected.

Your custom logic
[...]
can roughly be replicated with the two lines

parser.add_argument("first")
parser.add_argument("second", nargs="?")
[... extended example ...]

Thank you!

Cheers,
Cameron Simpson <[email protected]>
_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to