OSDN Git Service

split seed1 search -> seed1 tab & skill1 tab
[amulettoolsmh4/main.git] / view / singleton.py
1 # -*- coding: utf-8 -*-
2
3 u""" シングルトン用クラス。
4 2013/12/20 written by kei9
5
6 使用には
7 import singleton
8 class hoge:
9     __metaclass__ = singleton.Singleton
10     def __init__(...):
11     ....
12 のようにすればよい
13 """
14
15 class Singleton(type):
16     def __init__(self, *args):
17         type.__init__(self, *args)
18         self._instance = None
19
20     def __call__(self, *args):
21         if self._instance is None :
22             self._instance = type.__call__(self, *args)
23         return self._instance