title: Get variable from file which is importing my function in python
body: <p>I have 2 files:</p>
  
  <p><strong><code>Main.py</code></strong></p>
  
  <pre><code>from test import test
  def main():
      sol = 'hello'
      if test() == sol:
          print('Yes')
      else:
          print('No')
  </code></pre>
  
  <p><strong><code>test.py</code></strong></p>
  
  <pre><code>def test():
      return 'hello'
  </code></pre>
  
  <p>Is there a way to access the <strong>sol</strong> variable in my test function which is in another file? I'd like to do something like this:</p>
  
  <pre><code>def test():
      return sol
  </code></pre>
  
  <p>This way it's always the same as the variable in Main.py. I tried a solution which is mentioned on <a href="https://stackoverflow.com/questions/38632067/python-extract-variables-from-an-imported-file">Python extract variables from an imported file</a> but it didn't work for me. Thank you for any help</p>
  
  <p>Edit: I'd like to do it without changing the Main.py file</p>