optparse Questions

3

Using python optparse.py, is there a way to work out whether a specific option value was set from the command line or from the default value. Ideally I would like to have a dict just like default...
Foggia asked 7/4, 2010 at 14:27

6

Solved

Using python's optparse module I would like to add extra example lines below the regular usage output. My current help_print() output looks like this: usage: check_dell.py [options] options: -h, ...
Monochord asked 7/12, 2009 at 1:48

2

Solved

This is more like a code design question. what are good default values for optional options that are of type string/directory/fullname of files? Let us say I have code like this: import optparse ...
Polynomial asked 22/12, 2013 at 22:48

4

Solved

I'd like to be able to use ruby's OptionParser to parse sub-commands of the form COMMAND [GLOBAL FLAGS] [SUB-COMMAND [SUB-COMMAND FLAGS]] like: git branch -a gem list foo I know I could switc...
Demoralize asked 28/4, 2010 at 20:28

6

Solved

I have an application that allows you to send event data to a custom script. You simply lay out the command line arguments and assign what event data goes with what argument. The problem is that th...
Panelboard asked 4/8, 2009 at 18:32

3

Solved

I'm making a shell script with the optparse module, jut for fun, so I wanted to print a nice ascii drawing in place of the description. Turns out that this code: parser = optparse.OptionParser( ...
Denitadenitrate asked 22/8, 2010 at 21:3

1

Solved

I currently script in Python but I wish to try Ruby for several reasons. I've looked at a lot of sample code and read a lot of documentation over the last week. One point of concern I have is the l...
Heidt asked 18/3, 2013 at 21:51

5

Solved

In python's OptionParser, how can I instruct it to ignore undefined options supplied to method parse_args? e.g. I've only defined option --foo for my OptionParser instance, but I call parse_args wi...
Secretory asked 11/12, 2009 at 0:53

4

Solved

I'm trying to unit test some code that looks like this: def main(): parser = optparse.OptionParser(description='This tool is cool', prog='cool-tool') parser.add_option('--foo', action='store', h...
Dithyramb asked 8/1, 2009 at 23:37

2

Solved

I currently have a python file that utilizes sys.argv[1] to accept a string at the command line. It then performs operations on that string and then returns the modified string to the command line....
Presber asked 31/8, 2012 at 20:55

2

Solved

I've got a dozen programs that can accept input via stdin or an option, and I'd like to implement the same features in a similar way for the output. The optparse code looks like this: parser.add_...
Boogiewoogie asked 22/10, 2011 at 22:18

3

Solved

According to PEP 257 the docstring of command line script should be its usage message. The docstring of a script (a stand-alone program) should be usable as its "usage" message, printed when ...
Mondragon asked 11/8, 2009 at 12:14

1

With optparse, is there a simple way to define negative options, e.g., --no-cleanup? I did it this way, but it's cumbersome and bug-prone, especially due to the None check which is easy to forget ...
Danieladaniele asked 29/3, 2012 at 22:12

3

Solved

I've started a serious attempt to learn some Python as my first programming language with some basic knowledge on algorithms. Since everyone recommends that the best way to start is to find somethi...
Cockneyfy asked 23/3, 2012 at 19:5

1

Solved

When I run this sample from the OptionParser documentation: require 'optparse' options = {} OptionParser.new do |opts| opts.banner = "Usage: example.rb [options]" opts.on("-v", "--[no-]verbose",...
Dalenedalenna asked 6/3, 2012 at 3:20

1

Solved

I want to have params like this: program dothis --additional --options and: program dothat --with_this_option=value and I can't get how to do that. The only thing I managed to do is to use pa...
Order asked 2/2, 2012 at 18:22

2

Solved

Take the following rather standard code: from optparse import OptionParser opts = OptionParser() opts.add_option('-f', action="store_true") opts.add_option("-x", dest="x", type="int", default=1) ...
Reconciliatory asked 8/11, 2011 at 4:48

6

Solved

I've been using optparse for a while now, and would like to add the ability to load the arguments from a config file. So far the best I can think of is a wrapper batch script with the arguments h...
Cushiony asked 10/12, 2009 at 11:35

5

Solved

When using optparse i want to get the whole string after an option, but I only get part of it up to the first space. e.g.: python myprog.py --executable python someOtherProg.py What I get in 'e...
Inveterate asked 1/10, 2010 at 13:50

5

Solved

Here is an example of how I would like to call my script: python script.py -f file1.txt "string1" "string2" -f file2.txt "string3" "string4" Every file that goes as input will have 2 strings ass...
Sharrisharron asked 21/3, 2011 at 0:36

2

Solved

My Python script (for todo lists) is started from the command line like this: todo [options] <command> [command-options] Some options can not be used together, for example todo add --pos...
Bandit asked 28/4, 2010 at 12:39

3

Solved

Is it possible to make an option in optparse a mandatory?
Execratory asked 4/1, 2011 at 11:8

1

Solved

How can I take the opt result of opt, args = parser.parse_args() and place it in a dict? Python calls opt a "Values Instance" and I can't find any way to turn a Values Instance into a list or di...
Gratia asked 18/11, 2009 at 3:31

3

Solved

I'm writing a python script which I would like to be able to both call from the command line and import as a library function. Ideally the command line options and the function should use the same ...
Travelled asked 2/10, 2009 at 23:11

4

Solved

I'm writing a small program that's supposed to execute a command on a remote server (let's say a reasonably dumb wrapper around ssh [hostname] [command]). I want to execute it as such: ./floep [c...
Choosy asked 3/4, 2009 at 22:52

© 2022 - 2024 — McMap. All rights reserved.