1234567891011121314151617181920212223 |
- class Test(object):
- _instance = None
- def __new__(cls, *args, **kwargs):
- if cls._instance is None:
- cls._instance = super(Test, cls).__new__(*args, **kwargs)
- return cls._instance
- def __init__(self):
- super(Test, self).__init__()
- @classmethod
- def foo(cls):
- print("classmethod")
- def foo(self):
- print("method", self)
- Test.foo()
- Test().foo()
|