6
0

testing.py 419 B

1234567891011121314151617181920212223
  1. class Test(object):
  2. _instance = None
  3. def __new__(cls, *args, **kwargs):
  4. if cls._instance is None:
  5. cls._instance = super(Test, cls).__new__(*args, **kwargs)
  6. return cls._instance
  7. def __init__(self):
  8. super(Test, self).__init__()
  9. @classmethod
  10. def foo(cls):
  11. print("classmethod")
  12. def foo(self):
  13. print("method", self)
  14. Test.foo()
  15. Test().foo()