title: Why doesn't my Python script recognize a class from an imported module?
body: <p><strong>collection.py</strong></p>
  
  <pre><code>import sys
  import os
  import pymongo
  from pymongo import MongoClient
  
  class Collection():
      """returns a collection curser from mongodb"""
  
      client = MongoClient()
  
      def __init__(self, db, collection_name):
          self.db = db
          self.collection_name = collection_name
  
      def getCollection(self):
          data_base = getattr(self.client, self.db)
          collObject = getattr(data_base, self.collection_name)
          return collObject
  </code></pre>
  
  <p><strong>main.py</strong></p>
  
  <pre><code>import sys
  import os
  import collection
  
  def main():
      pass
  
  if __name__ == '__main__':
      print"Begin Main"
  
      agents = Collection('hkpr_restore','agents')
      print "agents is" , agents
  </code></pre>
  
  <p>These files are in the same directory. When I run <code>main.py</code>, however, I get an error:</p>
  
  <pre><code>Begin Main
  Traceback (most recent call last):
    File "main.py", line 23, in &lt;module&gt;
      agents = Collection('hkpr_restore','agents')
  NameError: name 'Collection' is not defined
  </code></pre>
  
  <p>From what I've read, if the files are in the same directory, all I need to do is use <code>import collection</code>.  </p>
  
  <p>Am I missing something?</p>