On Thu, Sep 1, 2011 at 5:12 PM, Fulvio <fa...@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
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to