Python traceback with module names
<p>Stack traces in Python show file paths.  Is there any way to get them to show fully qualified function names instead?</p>

<p>Example:</p>

<pre><code>class Foo(object):
    def bar(self):
        raise Exception, "Some error."

def inner():
    return Foo().bar()

def outer():
    return inner()
</code></pre>

<p>I'd like my output to look like this:</p>

<pre><code>In __main__.Foo.bar ("scratchpad.py", line 3)
   __main__.inner ("scratchpad.py", line 6)
   __main__.outer ("scratchpad.py", line 9)
Exception: Some error.
</code></pre>

<p>If it changes anything, I'm using Python 2.7.</p>

<hr>

<p>Here's what I have so far:</p>

<pre><code>import sys

class Foo(object):
    def bar(self):
        raise Exception, "Dummy value."

def inner():
    "Inner function..."
    return Foo().bar()

def outer():
    return inner()


try:
    outer()
except Exception, error:
    traceback = sys.exc_info()[2]
    while traceback is not None:
        frame = traceback.tb_frame
        print 'Name', frame.f_globals['__name__']+'.'+frame.f_code.co_name
        docs = frame.f_code.co_consts[0]
        if docs and docs != -1: # docs can be None or -1.
            print 'Docs "%s"' % docs
        print 'Args', frame.f_code.co_argcount
        print 'File "%s", line %d' % (frame.f_code.co_filename, frame.f_lineno)
        print
        traceback = traceback.tb_next
</code></pre>

<p>When I run it, it prints</p>

<pre><code>$ python pretty-stack.py
Name __main__.&lt;module&gt;
Args 0
File "pretty-stack.py", line 28

Name __main__.outer
Args 0
File "pretty-stack.py", line 14

Name __main__.inner
Docs "Inner function..."
Args 0
File "pretty-stack.py", line 11

Name __main__.bar
Args 1
File "pretty-stack.py", line 7
</code></pre>

<p>It's almost there, but I have trouble with important use cases.  For example, I can't get the class name <code>Foo</code> for <code>Foo.bar()</code>.</p>
