Optparse buggy?

Jason Swails jason.swails at gmail.com
Thu Sep 1 17:27:25 EDT 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()

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

-------------- 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