title: Is there a way in python to execute all functions in a file without explicitly calling them?
body: <p>Is there a library or a python magic that allows me to execute all functions in a file without explicitly calling them. Something very similar to what pytest is doing - running all functions that start with 'test_...' without ever registering them anywhere.</p>
  
  <p>For example assume I have a file a.py:</p>
  
  <pre><code>def f1():
      print "f1"
  
  def f2():
      print "f2"
  </code></pre>
  
  <p>and assume I have file - my main file - main.py:</p>
  
  <pre><code>if __name__ == '__main__':
      some_magic()
  </code></pre>
  
  <p>so when I call:</p>
  
  <pre><code>python main.py
  </code></pre>
  
  <p>The output would be:</p>
  
  <pre><code>f1
  f2
  </code></pre>