Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. # 싱글톤 패턴 싱글톤은 오직 하나의 인스턴스와 잘 정의된 액세스 포인트를 갖는 클래스다 ## 요구사항 - 클래스는 잘 알려진 액세스 포인트를 통해 접근 가능하며 단 하나의 인스턴스만 가져야 한다. - 클래스는 패턴을 망치지 않으면서 상송을 통해 확장할 수 있어야 한다 - 파이썬에서 가장 단순한 싱글톤 구현은 다음과 같다. 기본 객체 타입의 `__new__` 메소드를 오버라이드해 수행된다. <code> # singleton.py class Singleton(object): _instance = None def __new__(cls): if cls._instance == None: cls._instance = object.__new__(cls) return cls._instance </code> open/싱글톤-패턴.txt Last modified: 2024/10/05 06:15by 127.0.0.1