optparse TypeError
Michele Simionato
michele.simionato at gmail.com
Mon Jun 28 23:31:53 EDT 2010
More information about the Python-list mailing list
Mon Jun 28 23:31:53 EDT 2010
- Previous message (by thread): optparse TypeError
- Next message (by thread): video
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Jun 28, 11:47 pm, rantingrick <rantingr... at gmail.com> wrote: > Give your *script* an > enema, and do *yourself* a favor by harnessing the simplistic elegance > of the "optphart" module instead! > > #-- Start Script --# > def optphart(args): > d = {'args':[]} > for arg in args: > if arg.startswith('-'): > key, value = arg.split('=', 1) > options = value.split(',') > if len(options) > 1: > d[key[1:]] = options > else: > d[key[1:]] = [value] > else: > d['args'].append(arg) > return d Probably I should not be answering this, but try to implement the parsing required by the OP with this approach, including the generation of the usage message and the error checking. Just try. M. S.
- Previous message (by thread): optparse TypeError
- Next message (by thread): video
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list