N
Neil Zanella
Hello,
Is this the correct way to code multi-instance singleton in Python?
It seems to do the trick for me but I appreciate any criticism as I
am somewhat new to Python.
Thanks,
Neil
#!/usr/bin/python
class B:
x = 0
y = 1
def foo(): print B.x
foo = staticmethod(foo)
def bar(): print B.y; B.y += 1
bar = staticmethod(bar)
if __name__ == "__main__":
B.foo()
B.bar()
B.foo()
B.bar()
B.bar()
Is this the correct way to code multi-instance singleton in Python?
It seems to do the trick for me but I appreciate any criticism as I
am somewhat new to Python.
Thanks,
Neil
#!/usr/bin/python
class B:
x = 0
y = 1
def foo(): print B.x
foo = staticmethod(foo)
def bar(): print B.y; B.y += 1
bar = staticmethod(bar)
if __name__ == "__main__":
B.foo()
B.bar()
B.foo()
B.bar()
B.bar()