2008-02-05
■ [デザインパターン] Singletonパターン

ASPN Python Cookbook : Simple Singleton via http://memo.jj-net.jp/154
注意!!(2008/02/25追記) : 以下の Singleton クラスにはエラーがある。こちらを参照すること
class Singleton( type ): def __init__( self, *args ): type.__init__( self, *args ) self._instance = None def __call__( self, *args ): if self._instance is None: self._instance = type.__call__( self, *args ) return self._instance class Test: __metaclass__ = Singleton def __init__( self ): pass
さて・・・ __metaclass__ の意味が分からんが・・・
良い解説してるサイト or 本は無いものか・・・?
コメント
トラックバック - http://python.g.hatena.ne.jp/nelnal_programing/20080205