title: How to get a list of classes and functions from a python file without importing it
body: <p>I have a python file with some classes and functions defined in it:</p>
  
  <pre><code>class A(object):
      def __init__(self, an_arg, a_default_arg=None):
          pass
  
  def doStuff(an_other_arg, an_other_default_arg=None):
      pass
  </code></pre>
  
  <p>And I want to get a list of all classes and functions in this file. (their names and parameter definitions are enough)</p>
  
  <p>Now, I do know you can do this with <code>__import__(module_descriptor)</code> and <code>inspect</code>, but this is not an option as the file I'm scanning is from an untrusted source.</p>
  
  <p>My first reaction was to try and create a safe environment to import them, but this seems impossible according to other stackoverflow-questions.</p>