<div class="gmail_quote">On Thu, Dec 22, 2011 at 1:11 PM, Saqib Ali <span dir="ltr"><<a href="mailto:saqib.ali.75@gmail.com">saqib.ali.75@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

MYCLASS.PY:<br><br><div>#!/usr/bin/env python</div><div>import os, sys, string, time, re, subprocess</div><div>import Singleton</div></blockquote><div><br></div><div>This imports the module Singleton, not the class or function.</div>

<div><br></div><div>There are two options to deal with this:</div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div class="gmail_quote"><div>from Singleton import Singleton</div></div></blockquote>
imports the name Singleton from the module Singleton, which will be what you are probably expecting. If you wish to keep the namespace, you can also change your call from @Singleton to @Singleton.Singleton<div>
<div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><br></div><div>@Singleton</div><div>
class myClass:</div><div>    </div><div>    def __init__(self):</div><div>        print 'Constructing myClass'</div><div><br></div><div>    def __del__(self):</div><div>        print 'Destructing myClass'<br>


<br><br>SINGLETON.PY:<br><br><br><div>#!/usr/bin/env python</div><div>import os, sys, string, time, re, subprocess</div><div>import Singleton</div><div><br></div><div><br></div><div>@Singleton</div>
<div>class myClass:</div><div>    </div><div>    def __init__(self):</div><div>        print 'Constructing myClass'</div><div><br></div><div>    def __del__(self):</div><div>        print 'Destructing myClass'<br>


<br>TRACEBACK:<br><br><div>>>> import myClass</div><div>Traceback (most recent call last):</div><div>  File "<stdin>", line 1, in <module></div><div>  File "myClass.py", line 6, in <module></div>


<div>    @Singleton</div><div>TypeError: 'module' object is not callable</div></div><div><br></div><br><br></div>- Saqib<br><br><br>
<br><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<br>
</blockquote>
<br></div></div>
Post the code, and the traceback.<br><font color="#888888">
<br>
~Ethan~</font></blockquote></div>
<br>--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
<br></blockquote></div><br></div>