Singleton

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Wed Oct 10 21:56:20 EDT 2007


On Wed, 10 Oct 2007 17:37:53 +0200, Diez B. Roggisch wrote:

>> Two borgs, or two million, the whole point of using borgs is that it
>> doesn't matter.
> 
> It does matter where the classes live (module-wise). Which is the
> problem the OP had, borg or not to borg.


Gotcha. Thanks for the demonstration code, that makes it clear.

[snip]


> You will see that there are _two_ different Borg-Cubes, as the output
> indicates. This has hit me more than once, and Carl Banks pointed that
> error out to the OP.
> 
> And if you'd follow your own advice of " take each word to have it's
> normal English meaning," then the OP is not
> 
> "struggling to get a singleton working"
> 
> but struggling to get "some sort of singleton working", as you cite
> yourself, and first tried to implement his needs using no
> singleton-recipe (or borg pattern) but a module:

Using modules *is* a recipe for getting singletons, as the OP clearly 
understood. 


> Which didn't work out for the same reason his singleton approach didn't
> work and your beloved Borg-pattern doesn't as well.

It's not my beloved Borg-pattern. My original post asked: "Why do you 
need only one instance?" and suggested that *perhaps* he should 
*consider* an alternative. Sheesh. It's not like I said that the Borg 
solves every problem every time.



-- 
Steven.



More information about the Python-list mailing list