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 6919927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:05:02+00:00 2026-05-27T10:05:02+00:00

within the frame of a python application, I need to make calls to several

  • 0

within the frame of a python application, I need to make calls to several of my scripts that were largely using optparse. They all have an entry point of this form :

if __name__ == '__main__':
    mains(sys.argv)

I just called my main function mains thinking that my problem initially came from there. Then, the mains always start like that, as an example :

def mains( argv ):
    parser = OptionParser()
    parser.add_option("-f", "--file", dest="filename", help="write result to FILE", metavar="FILE")
    parser.add_option("-x", "--filter", dest="filterset", help="filters", metavar="FILTERS")
    parser.add_option("-n", "--nameonly", dest="nameonly", help="nameonly", metavar="NAME_ONLY")
    parser.add_option("-z", "--ignorezeros", dest="ignorezeros", help="ignorezeros", metavar="IGNORE_ZEROS")
    parser.add_option("-y", "--xfilter", dest="xfilter", help="xfilter", metavar="X_FILTERS")

The argv here isn’t used by optparser, I do not find how to pass it to it. From my actual principal script, I thought I could call these mains by just passing the arguments as a list. Obvioulsy, in the current state the sub scripts will always pick up the command line… How to pass the arguments myself instead ?

UPDATE : my script trying to make those calls to subcripts is called this way from the console :

start.py -df

The problem : optparse from the first subscript tells me that “d” is not a valid option, which shows it is picking the console arguments at the moment.

  • 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-27T10:05:03+00:00Added an answer on May 27, 2026 at 10:05 am

    You left out the call to parse your options:

    parser.parse_args(argv)
    

    parse_args takes an optional argument which will be used for parsing rather than sys.argv.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UIView subclass that draws a curved line within it's frame (using
I need to access and element from within a frameset frame. For example if
I have a legacy website using frames. The pages within the frame do not
I have a small dialog frame that appears, and within this frame are a
I have an Android application that has one section loading a web page within
I'm working on a website that uses not just frames, but frames within frames
Within an application, I've got Secret Keys uses to calculate a hash for an
Within Ruby on Rails applications database.yml is a plain text file that stores database
Within c#, I need to be able to Connect to a remote system, specifying
Within my Subversion project I have a few directories that contain other open source

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.