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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:37:31+00:00 2026-06-15T11:37:31+00:00

My program currently consists of 2 .py files. I run the main part of

  • 0

My program currently consists of 2 .py files.

I run the main part of the code in pypy (which is much faster) and then I open a second file in python that plots my data using matplotlib.pyplot.

I have managed to open the using:

subprocess.Popen(['C:\\python26\\python.exe ','main_plot.py',])

which opens my second file…

import matplotlib.pyplot as pyplot
def plot_function(NUMBER):
    '''some code that uses the argument NUMBER'''
    pyplot.figure()
    ---plot some data---
    pyplot.show()

However, I would like to be able to pass arguments to the plot_function that opens in python. Is that possible?

  • 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-06-15T11:37:35+00:00Added an answer on June 15, 2026 at 11:37 am

    Yes, the Popen constructor takes a list of length n. See the note here. So just add the arguments to main_plot.py to your list:

    subprocess.Popen(['C:\\python26\\python.exe ','main_plot.py','-n',1234])
    

    EDIT (to respond to your edit):

    You need to modify main_plot.py to accept a command line argument to call your function. This will do it:

    import matplotlib.pyplot as pyplot
    def plot_function(NUMBER):
        '''some code that uses the argument NUMBER'''
        pyplot.figure()
        ---plot some data---
        pyplot.show()
    
    import argparse
    if __name__=="__main__":
        argp=argparse.ArgumentParser("plot my function")
        argp.add_argument("-n","--number",type=int,default=0,required=True,help="some argument NUMBER, change type and default accordingly")
        args=argp.parse_args()
        plot_function(args.number)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently trying to optimize my program. I have a large database which consists
I've written some code, which currently consists of two windows to show different stages
Say I have a command line C program which is currently executing, and I
I am currently making a program which is supposed to prompt the user to
I am currently in the middle of a code cleanup of my solution, which
I'm working on converting an old C program (currently run on UNIX) into our
I am attempting to build a simple OpenGL 3.2 program which consists of a
I have written a program that consists of roughly 3000 lines of code. The
I'm currently trying to put part of a complex program into a dynamic library.
This program currently inputs an image of a coin, thresholds it, binarizes it, and

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.