BTW Here is the 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
Here is Singleton.py:
class Singleton:
def __init__(self, decorated):
self._decorated = decorated
def Instance(self):
try:
return self._instance
except AttributeError:
self._instance = self._decorated()
return self._instance
def __call__(self):
raise TypeError(
'Singletons must be accessed through the `Instance`
method.')
Here is myClass.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'
--
http://mail.python.org/mailman/listinfo/python-list