Borg Pattern Class usable from other classes?

Graham Ashton graz at mindless.com
Thu Oct 11 12:01:24 EDT 2001


In article <mailman.1002804792.23588.python-list at python.org>, "Jan Wender"
<j.wender at science-computing.de> wrote:

> Hi,
> I tried to use the Borg Pattern from Alex Martelli
> (http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66531). [snip]

I don't know, and I'm completely and utterly stumped. I'm quite concerned
that I can't get it to work either - I'm obviously missing something big
here. I've used Borg <troll>er, shouldn't it be called a singleton?</troll>
myself in one of my libraries, but it works fine. However, I only ever
call it from outside the module that it's defined in.

Having hacked around with it I can only conclude that when called from
within a different module, the Borg class statement is re-evaluated, and
"__s = {}" is re-evaluated. That doesn't make any sense though, so I must
be wrong. __s is certainly empty when called from Test.__init(), but I
don't know why.

Arggghhhhh!

--
Graham



More information about the Python-list mailing list