Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #2762

How to use optparse without the command line?

From markolopa <marko.loparic@gmail.com>
Newsgroups comp.lang.python
Subject How to use optparse without the command line?
Date 2011-04-07 01:37 -0700
Organization http://groups.google.com
Message-ID <531582e4-3eac-4dd6-aa87-17b869cd8f84@w6g2000vbo.googlegroups.com> (permalink)

Show all headers | View raw


Hello,

Is there support/idioms/suggestions for using optparse without a
command line?

I have a code which used to be called through subprocess. The whole
flow of the code is based on what 'options' object from optparse
contains.

Now I want to call this code without subprocessing. What I did first
was to build a "fake" command-line and use

options, args = parser.parse_args(fake_cmdline)

But I find it dumb to encode and decode a dictionary... So I would
like to know how I if there is a good way of passing a dictionary to
optparse and benefiting from its option management (check, error
detection, etc).

Thanks a lot!
Marko

Back to comp.lang.python | Previous | NextNext in thread | Find similar


Thread

How to use optparse without the command line? markolopa <marko.loparic@gmail.com> - 2011-04-07 01:37 -0700
  Re: How to use optparse without the command line? Karim <karim.liateni@free.fr> - 2011-04-08 23:58 +0200
    Re: How to use optparse without the command line? markolopa <marko.loparic@gmail.com> - 2011-04-13 06:18 -0700

csiph-web