How Do I Get the Module Name of an Object's Class Definition Rather Than the Module Name of the Object's Instantiation?
<p>In python 2.5, I have the following code in a module called modtest.py:</p>

<pre><code>def print_method_module(method):
    def printer(self):
        print self.__module__
        return method(self)
    return printer

class ModTest():

    @print_method_module
    def testmethod(self):
        pass

if __name__ == "__main__":
    ModTest().testmethod()
</code></pre>

<p>However, when I run this, it prints out:</p>

<pre><code>__main__
</code></pre>

<p>If I create a second file called modtest2.py and run it:</p>

<pre><code>import modtest

if __name__ == "__main__":
    modtest.ModTest().testmethod()
</code></pre>

<p>This prints out:</p>

<pre><code>modtest
</code></pre>

<p>How can I change the decorator to always print out <code>modtest</code>, the name of the module in which the class is defined?</p>
