Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 789225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:29:23+00:00 2026-05-14T21:29:23+00:00

This error is done strictly by following examples found on the docs . And

  • 0

This error is done strictly by following examples found on the docs. And you can’t find any clarification about it anywhere, be it that long long docs page, google or stackoverflow. Plus, reading optparse.py shows OptionGroup is there, so that adds to the confusion.

Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29) 
>>> from optparse import OptionParser
>>> outputGroup = OptionGroup(parser, 'Output handling')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'OptionGroup' is not defined

I bet it will take less than 1 minute for someone to spot my error. 🙂

Yes, that means I knew the answer, but since this took me so long to discover I wanted to “document” it here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T21:29:23+00:00Added an answer on May 14, 2026 at 9:29 pm

    Perhaps this is another example of why it is better to import modules than functions from modules.

    OptionGroup is defined in the module optparse.
    The command

    from optparse import OptionParser

    puts OptionParser in the global namespace, but neglects OptionGroup entirely.

    To fix the code, import the optparse module, and access its parts like so:

    import optparse
    parser = optparse.OptionParser()
    outputGroup = optparse.OptionGroup(parser, 'Output handling')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im getting this error. ReferenceError: Can't find variable: cordova at file:///android_asset/www/childbrowser.js:87 I have done
I have an error/exception that is thrown by a particular method. Any time this
When I trying to commit I get this error. What that was done, I
I've done quite a bit of googling on this error but have had no
This is done manually by going to the Error List output window and double-clicking
How to resolve this error and get my git push done as quick as
I have a script and I'm almost done but I get this error and
I'm installing Drupal like I've always done and I start to see this error
Has anyone heard of this error before: I have a Java 5 application, that
I am getting this error on the error console and can't seem to figure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.