title: Calling if __name__ == '__main__': in one module from a function in another module
body: <p>I need to call <code>if __name__ == '__main__'</code>, that calls several classes in one module, <code>Module 1</code>, in a function, <code>function1</code>, that's in a class in a second module, <code>Module 2</code>. </p>
  
  <p>I can't use <code>def main()</code>- solution in <code>Module 1</code> instead of <code>if __name__ == '__main__'</code>, since the module has several classes and functions connected to <code>Class_1</code> in <code>Module 1</code> that only works with <code>print('I am:', __name__)</code> and <code>if __name__ == '__main__':</code>. </p>
  
  <p>So my question is how I can call main: <code>if __name__ == '__main__'</code> from <code>Class_1()</code> in <code>function1</code> in <code>Class_2()</code> in <code>Module 2</code>?</p>
  
  <p><strong>Module 1</strong></p>
  
  <pre><code>print('I am:', __name__)
  
  class Class_1():
     ....code...
  
  # calling everything in the module that
  if __name__ == '__main__':
  </code></pre>
  
  <p><strong>Module 2</strong></p>
  
  <pre><code># if __name__ == '__main__' from Module 1 should be called in function 1
  
  
  class Class_2():
     .... code..
  
     def function1:
      --- calling main if __name__ == '__main__' from Module 1
  </code></pre>