An example using only Unix style options:
>>> import getopt
>>> args = '-a -b -cfoo -d bar a1 a2'.split()
>>> args
['-a', '-b', '-cfoo', '-d', 'bar', 'a1', 'a2']
>>> optlist, args = getopt.getopt(args, 'abc:d:')
>>> optlist
[('-a', ''), ('-b', ''), ('-c', 'foo'), ('-d', 'bar')]
>>> args
['a1', 'a2']
% Using long option names is equally easy:
© Yves Guidet jeudi 9 juillet 2020, 09:48:17 (UTC+0200) (bella ubuntu, site printemps) yves.guidet@gmail.com