title: Get all class names in a Python package
body: <p>I need to get the list of all classes in Python package.
  At first I get all filenames (it works fine, took it from stackoverflow):</p>
  
  <pre><code>from os import listdir, getcwd
  from os.path import isfile, join
  mypath = getcwd()
  onlyfiles = [ f for f in listdir(mypath) if isfile(join(mypath,f)) ]
  </code></pre>
  
  <p>Then I inspect all files and it doesn't work properly:</p>
  
  <pre><code>for x in onlyfiles:
      for name, obj in inspect.getmembers(x):
          if inspect.isclass(obj):
              print obj
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>&lt;type 'str'&gt;
  ....
  &lt;type 'str'&gt;
  </code></pre>
  
  <p>However, the following code works properly:</p>
  
  <pre><code>    for name, obj in inspect.getmembers(example.py):
          if inspect.isclass(obj):
              print obj
  </code></pre>
  
  <p>Could you help me to figure out what the mistake is?</p>