タグ

関連タグで絞り込む (1)

タグの絞り込みを解除

Pythonとclassに関するjimo1001のブックマーク (1)

  • __new__ の調査便乗 - 銀月の符号

    RRF言語研究所さんの『http://d.hatena.ne.jp/rockRicefield/20090915/1253002685』に惹かれて。 Python 暦浅いはずなのにもう __new__ の魔窟へ突入とは。すごいです、友達になってください>< そして自分も __new__ について復習してみた。 クラスオブジェクトを呼び出した時の動作 普通の自作クラスとそのインスタンスの生成はこのような感じ。 >>> class Spam(object): ... def __init__(self, n): ... self.n = n ... >>> spamins1 = Spam(7) >>> type(spamins1) <class '__main__.Spam'> >>> spamins1.n 7 この spam(7) のコンストラクタ呼び出し部分を分解するとこんな感じ。 >>>

    __new__ の調査便乗 - 銀月の符号
  • 1