2009-07-11から1日間の記事一覧
Python Programming Language -- Official Website まずはこのサイトのDownloadから、 Python2.6(2009/06/26現在)をダウンロード Pythonドキュメント翻訳プロジェクト リファレンスには、CHM形式が関数名から検索できるので便利です。 Pythonチュートリア…
『Rubyによるデザインパターン』(ラス・オルセン著 ピアソン・エデュケーション刊)の例をPythonに変換して書いています。目次 Strategyパターンでは、他のオブジェクトに委譲する事で、アルゴリズムを動的に変更することをしました。たとえば、HTMLを出力…
ところで、自動委譲と__getattr__の方法1・方法2にはちょっとした欠陥があります。 w = WriterDecorator1(SimpleWriter("test.txt")) print(w.writeline) # => <bound method SimpleWriter.writeline of <SimpleWriter object at 0x00B008B0>> WriterDecorator1のメソッドのはずなのに、SimpleWriterのメソッドの名前が表示されて</bound>…
『Rubyによるデザインパターン』(ラス・オルセン著 ピアソン・エデュケーション刊)の例をPythonに変換して書いています。目次 Singletonパターン (1) Singletonパターン (2) - ぜ〜んぶクラスメソッド Singletonパターン (3) - モジュール Singletonパター…
Singletonパターン (1) Singletonパターン (2) - ぜ〜んぶクラスメソッド Singletonパターン (3) - モジュール Singletonパターン (4) - メタクラスを使った方法 Singletonパターン (5) - Borgの方法 Pythonにはクラスメソッドがあります。クラスメソッドは…
Singletonパターン (1) Singletonパターン (2) - ぜ〜んぶクラスメソッド Singletonパターン (3) - モジュール Singletonパターン (4) - メタクラスを使った方法 Singletonパターン (5) - Borgの方法 実はPythonには、どんなクラスも簡単にSingleton化する方…
Singletonパターン (1) Singletonパターン (2) - ぜ〜んぶクラスメソッド Singletonパターン (3) - モジュール Singletonパターン (4) - メタクラスを使った方法 Singletonパターン (5) - Borgの方法 Singletonにはサブクラス化したとき、 各サブクラス毎に…
Singletonパターン (1) Singletonパターン (2) - ぜ〜んぶクラスメソッド Singletonパターン (3) - モジュール Singletonパターン (4) - メタクラスを使った方法 Singletonパターン (5) - Borgの方法 クラスはインスタンスの生成装置だと言えます。そしてク…