Is there such a thing as a static constructor in Python?
How do I implement a static constructor in Python?
Here is my code... The __init__
doesn't fire when I call App like this. The __init__
is not a static constructor or static initializer.
App.EmailQueue.DoSomething()
I have to call it like this, which instantiates the App class every time:
App().EmailQueue.DoSomething()
Here is my class:
class App:
def __init__(self):
self._mailQueue = EmailQueue()
@property
def EmailQueue(self):
return self._mailQueue
The problem with calling __init__
every time is that the App object gets recreated. My "real" App class is quite long.
question from:
https://stackoverflow.com/questions/7396092/is-there-a-static-constructor-or-static-initializer-in-python 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…