title: Executing a python file from another
body: <p>I'm trying to make a compilation of all my python projects so I can document my progress as I continue to learn. In my quest to learn more, I tried learning some basic I/O. I've structured my library to have an index program, <code>start_here.py</code> at the top of my directory, a subdirectory named &quot;projects&quot;, and 2 files <code>dice_app.py</code> and <code>text_to_math.py</code> in that subdirectory.</p>
  <p>I'm trying to structure this so the user manually activates <code>start_here.py</code>, then it opens a readme file with instructions on how to use my library. I can successfully read the readme and project list txt files. The struggle I'm having right now is executing either the dice app or text to math from start_here.</p>
  <p>This is my current system (does not work):</p>
  <pre><code>f = open(&quot;readme_files/index.txt&quot;)
  p = open(&quot;readme_files/projects.txt&quot;)
  
  print(f.read())
  
  func = 0
  while True:
      func = int(input(&quot;Requested Operation: &quot;))
  
      if func == 0:
          print(p.read())
      elif func == 1:
          exec(&quot;projects/dice_app.py&quot;)
          break
      elif func == 2:
          exec(&quot;projects/text_to_math.py&quot;)
          break
      else:
          print(&quot;Invalid operation. Please try again.&quot;)
  </code></pre>
  <p>I've quintuple-checked that I have the correct relative paths and there are no misspellings for any file names. I've tried import statements but when I did that it automatically executed text_to_math, the second file in the projects subdirectory.</p>
  <p>I'm not trying to execute a specific function from the file, but run the entire thing start to finish. What can I do to get this to work?</p>
  <p>P.S. I am very new to python so I don't know the &quot;right way&quot; to organize files but this is how my directory is set up.
  <a href="https://i.stack.imgur.com/4xFPk.png" rel="nofollow noreferrer">my file structure</a></p>