Title: optparse doex not export make_option
Type: behavior Stage:
Components: Documentation, Library (Lib) Versions: Python 2.6, Python 2.5
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: bluebird, georg.brandl
Priority: normal Keywords:

Created on 2009-02-09 13:23 by bluebird, last changed 2009-03-31 19:12 by georg.brandl. This issue is now closed.

Messages (2)
msg81456 - (view) Author: Bluebird (bluebird) Date: 2009-02-09 13:23
The documentation of optparse mentions make_option() as the standard way 
to create an option list:

For example, in the doc of python 2.5:

==== Populating the parser 

pass it an Option instance (as returned by make_option()) 


option_list = [
    make_option("-f", "--filename",
                action="store", type="string", dest="filename"),
    make_option("-q", "--quiet",
                action="store_false", dest="verbose"),

(make_option() is a factory function for creating Option instances; 
currently it is an alias for the Option constructor. A future version of 
optparse may split Option into several classes, and make_option() will 
pick the right class to instantiate. Do not instantiate Option 

However, make_option is not part of the function exported in the __all__ 
list of optparse. Strangely enough, this does not prevent to use 
make_option() in regular python scripts, but it does not work when 
packaging a python application, for example with pyinstaller.

The problem is also present in python 2.6

The fix is either to update the documentation to use Option() directly 
or to add make_option to __all__
msg84870 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-03-31 19:12
As commented in, make_option is the preferred way to create
options, so I've added it to __all__ in r70868.
Date User Action Args
2009-03-31 19:12:40georg.brandlsetstatus: open -> closed
resolution: fixed
messages: + msg84870
2009-02-09 13:23:11bluebirdcreate