Can't I define a decorator in a separate file and import it?

Saqib Ali saqib.ali.75 at gmail.com
Thu Dec 22 15:53:41 EST 2011



I'm using this decorator to implement singleton class in python:

http://stackoverflow.com/posts/7346105/revisions

The strategy described above works if and only if the Singleton is
declared and defined in the same file. If it is defined in a different
file and I import that file, it doesn't work.

Why can't I import this Singleton decorator from a different file?
What's the best work around?



More information about the Python-list mailing list