Top "Optparse" questions

optparse is a command-line argument parser for Python included in the standard library, deprecated since 2.7. It is also an unrelated command-line argument parser for Ruby.

Why use argparse rather than optparse?

I noticed that the Python 2.7 documentation includes yet another command-line parsing module. In addition to getopt and optparse we now …

python command-line optparse getopt argparse
understanding OptionParser

I was trying out optparse and this is my initial script. #!/usr/bin/env python import os, sys from optparse …

python optparse optionparser
Python argparse ignore unrecognised arguments

Optparse, the old version just ignores all unrecognised arguments and carries on. In most situations, this isn't ideal and was …

python argparse optparse
Python Optparse list

I'm using the python optparse module in my program, and I'm having trouble finding an easy way to parse an …

python optparse
python optparse, how to include additional info in usage output?

Using python's optparse module I would like to add extra example lines below the regular usage output. My current help_…

python optparse
Python optparse and spaces in an argument

When using optparse i want to get the whole string after an option, but I only get part of it …

python optparse
How to parse an argument without a name with Ruby's optparse

I need to parse a command line like script.rb <mandatory filename> [options] with optparse. Sure I can …

ruby optparse
How can I get optparse's OptionParser to ignore invalid options?

In python's OptionParser, how can I instruct it to ignore undefined options supplied to method parse_args? e.g. I've …

python optparse
Python Command Line Arguments: Calling a function

So I'm stuck on a project I'm working on that involves the command line in python. So basically, here's what …

python command-line command-line-arguments argparse optparse
Python optparse Values Instance

How can I take the opt result of opt, args = parser.parse_args() and place it in a dict? Python …

python dictionary optparse