On Thu, Dec 22, 2011 at 1:11 PM, Saqib Ali <saqib.ali...@gmail.com> wrote:

> MYCLASS.PY:
>
> #!/usr/bin/env python
> import os, sys, string, time, re, subprocess
> import Singleton
>

This imports the module Singleton, not the class or function.

There are two options to deal with this:

from Singleton import Singleton

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


>
> @Singleton
> class myClass:
>
>     def __init__(self):
>         print 'Constructing myClass'
>
>     def __del__(self):
>         print 'Destructing myClass'
>
>
> SINGLETON.PY:
>
>
> #!/usr/bin/env python
> import os, sys, string, time, re, subprocess
> import Singleton
>
>
> @Singleton
> class myClass:
>
>     def __init__(self):
>         print 'Constructing myClass'
>
>     def __del__(self):
>         print 'Destructing myClass'
>
> TRACEBACK:
>
> >>> import myClass
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "myClass.py", line 6, in <module>
>     @Singleton
> TypeError: 'module' object is not callable
>
>
>
> - Saqib
>
>
>
>
>
>>>
>> Post the code, and the traceback.
>>
>> ~Ethan~
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to