title: How to Determine The Module a Particular Exception Class is Defined In
body: <p>Note: i edited my Q (in the title) so that it better reflects what i actually want to know.  In the original title and in the text of my Q, i referred to the source of the thrown exception; what i meant, and what i should have referred to, as pointed out in one of the high-strung but otherwise helpful response below, is the module <strong>that the exception class is defined in</strong>. This is evidenced by the fact that, again, as pointed out in one of the answers below the answer to the original Q is that the exceptions were thrown from calls to cursor.execute and cursor.next, respectively--which of course, isn't the information you need to write the try/except block.</p>
  
  <p>For instance (the Q has nothing specifically to do with SQLite or the PySQLite module):</p>
  
  <pre><code>from pysqlite2 import dbapi2 as SQ
  
  try:
      cursor.execute('CREATE TABLE pname (id INTEGER PRIMARY KEY, name VARCHARS(50)')
  except SQ.OperationalError:
      print("{0}, {1}".format("table already exists", "... 'CREATE' ignored")) 
  </code></pre>
  
  #
  
  <pre><code>cursor.execute('SELECT * FROM pname')
  while 1:
      try:
          print(cursor.next())
      except StopIteration:
          break
  </code></pre>
  
  #
  
  <p>i let both snippets error out to see the exception thrown, then coded the try/finally blocks--but that didn't tell me anything about which module the exception class is defined. In my example, there's only a single imported module, but where there are many more, i am interested to know how an experienced pythonista identifies the exception source (search-the-docs-till-i-happen-to-find-it is my current method). </p>
  
  <p>[And yes i am aware there's a nearly identical question on SO--but for C# rather than python, plus if you read the author's edited version, you'll see he's got a different problem in mind.]        </p>