classification
Title: argparse documentation: Improve optparse section regarding allow_interspersed_args
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.2, Python 3.3, Python 3.4, Python 2.7
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: docs@python Nosy List: amcnabb, berker.peksag, docs@python, nejucomo, v+python
Priority: normal Keywords:

Created on 2012-07-05 22:41 by nejucomo, last changed 2018-08-14 12:34 by berker.peksag. This issue is now closed.

Messages (3)
msg164702 - (view) Author: Nefarious CodeMonkey, Jr. (nejucomo) Date: 2012-07-05 22:41
It was not obvious from the documentation on argparse how to emulate the optparse.OptionParser.allow_interspersed_args feature.

Please add something like the following to the section titled "Upgrading optparse code" (see: http://docs.python.org/library/argparse.html#upgrading-optparse-code )

"""
* If the optparse code sets allow_interspersed_args to False, then add an argparse positional argument with nargs=argparse.REMAINDER
"""
msg164755 - (view) Author: Glenn Linderman (v+python) * Date: 2012-07-06 20:43
See also issue 14191, which describes the problems of trying to make argparse achieve the goal of the default optparse handling of allow_interspersed_args !

The documentation for that branch of the feature is also seriously incomplete, and the workaround is more than a single line.
msg323511 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2018-08-14 12:34
ArgumentParser.parse_intermixed_arg() has been added in https://github.com/python/cpython/commit/0f6b9d230674da784ca79a0cf1a03d2af5a8b6a8 (Issue 14191) and the "Upgrading optparse code" section now has the following item:

* Replace optparse.OptionParser.disable_interspersed_args()
  by using ArgumentParser.parse_intermixed_args() instead of
  ArgumentParser.parse_args().

Closing this as 'outdated'.
History
Date User Action Args
2018-08-14 12:34:22berker.peksagsetstatus: open -> closed

nosy: + berker.peksag
messages: + msg323511

resolution: out of date
stage: resolved
2013-02-13 18:06:44amcnabbsetnosy: + amcnabb
2012-07-07 02:32:51terry.reedysetversions: - Python 3.1
2012-07-06 20:43:02v+pythonsetnosy: + v+python
messages: + msg164755
2012-07-05 22:41:12nejucomocreate