Re: Costly object creation (was : Having Trouble with Scoping Rules)



On 2006-01-31, bruno at modulix <onurb@xxxxxxxxxxx> wrote:
> See other answers in this thread for how to solve the UnboundLocalError
> problem.
>
> Now about your *real* problem - which is nothing new -, you may want to
> read about some known solutions:
>
> http://en.wikipedia.org/wiki/Singleton_pattern
> http://en.wikipedia.org/wiki/Proxy_pattern
> http://en.wikipedia.org/wiki/Lazy_initialization
> http://en.wikipedia.org/wiki/Memoization
>

No, I'm already quite certain that this is a Singleton--pythonically a
module-level instance of Something--I'm not thinking of it as "lazy
instantiated" 'cuz it's initialized at startup, but I suppose it
qualifies.

I considered using a Borg for this, but discarded the idea as "too
complicated for my needs--this will be easier to implement . . . "

Which I suppose it would be if I knew how correctly to use the "global"
keyword.

I don't need to restrict the actual class to One Instance so much as I'd
prefer that to be the default behavior. I can't think of a reason why
I'd want to subclass this, so I can't say whether it makes sense to
Borg/Highlander/Singleton it or not. For now, I'll Do The Simplest
Thing That Might Work and figure YAGNI (or IAGNI, I guess).

Thanks for the help.

.



Relevant Pages

  • Re: Open WiFi connections: Are you really stealing?
    ... You just ASSUME for no reason that people are doing something ... If you don't want to share, then restrict it. ... The reason most people don't do this is because they don't care. ... Suppose you bought a car with a toggle switch starting system. ...
    (rec.outdoors.rv-travel)
  • Re: getting the class name of a subclass
    ... > I have the following test code setup, trying to get the class name of a ... > subclass in the super class. ... > The reason i want this is since i have a number of dialogs all deriving ... > Is there a way to get the name of the subclass. ...
    (comp.lang.python)
  • getting the class name of a subclass
    ... I have the following test code setup, trying to get the class name of a subclass in the super class. ... The reason i want this is since i have a number of dialogs all deriving from the same super class. ...
    (comp.lang.python)
  • Re: how to restrict user from running some downloaded prgm?
    ... >> Well, for the reason part, here is a similar scenario. ... >> browser doesn't have their native language package. ... >> reason why I would like to restrict them from installing their own ... everyone in this list is all over policy! ...
    (comp.os.linux.security)
  • Re: limit Explorer browsing
    ... Generally speaking there's no reason to not allow the users to haveread access to most of the objects. ... -To restrict read access to AD or a given OU, you need to deny the read right. ...
    (microsoft.public.windows.server.active_directory)