Optparse buggy?

Jason Swails jason.swails at gmail.com
Thu Sep 1 23:27:25 CEST 2011


On Thu, Sep 1, 2011 at 5:12 PM, Fulvio <false at pp.jaring.my> wrote:

> Hello,
>
> I'm on python3.2, trying some experiment with OptionParser but no success
>
> >>> from optparse import OptionParser as parser
> >>> parser.add_option('-n','--new', dest='new')
>

Here you've imported parser as an alias to the OptionParser class.  You can
only use add_option() on an instance of that class.  Try this:

from optparse import OptionParser

parser = OptionParser()
parser.add_option('-n','--new',dest='new')

However, I think argparse has replaced optparse since Python 2.7 and
higher...

HTH,
Jason
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110901/60a06b15/attachment.html>


More information about the Python-list mailing list