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

  • Home
  • SEARCH
  • 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 7633751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:58:24+00:00 2026-05-31T06:58:24+00:00

I am new to python and I am trying to import some values from

  • 0

I am new to python and I am trying to import some values from one file to another.
I want my “program” to go from the main_file.py, to other files, like calculator.py, and then comme back to the main_file.py

To do so, I decided I’ll make a variable, previously_runned, which has the value ‘s’.
When the calculator would be activated, through the command, it would pick this variable
( and then give it back to the main_file.py, which will check the value of the variable, and then skip some lines of its own script, if the variable previously_runned has the value ‘s’)…:

    import os
    file_path = "calc.py"
    os.system(file_path)

…The calc.py would then pick the variables from main_file.py…:

import previously_runned from main_file

….Which returns:

  File "C:\Users\Kevin\Prog\Calc.py", line 72, in <module>
  import main_file
  ImportError: No module named main_file

Thanks for any help!

  • 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-31T06:58:25+00:00Added an answer on May 31, 2026 at 6:58 am

    When you do os.system(), it’s a totally separate Python process; it’s not going to share any variables with the Python instance that’s actually running the os.system() call. Meaning, if you change previously_runned from calc.py, it wouldn’t get reflected in your main file.

    What you really want to use here are functions; functions are much better units of control flow than modules. It sounds like you may not have gotten there with Python yet, so I think for now you should sit tight – what you’re trying is a good sign that you’re doing well, but it’s not really going to make sense until you’re comfortable defining and calling functions.

    Keep at it! Python is pretty awesome.

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

Sidebar

Related Questions

I'm really new to Python. I'm trying to import a third party module called
I'm trying to do some IP-lookup on Python Google Appengine like this: import pygeoip
I'm completely new to Python and I've been trying to make a fibonacci program
I'm trying to compile a simple Python program, that uploads files to an S3
Im new two python and am trying to grow a dictionary of dictionaries. I
I'm brand new at Python and I'm trying to write an extension to an
I am new to python and I am trying to implement rfind function using
New to Python, have a simple, situational question: Trying to use BeautifulSoup to parse
I'm new to Python and I have been trying to search through html with
I'm new to python but I've run into a hitch when trying to implement

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.