プロトタイプベース・オブジェクト指向 at TECH
[2ch|▼Menu]
433:デフォルトの名無しさん
04/02/08 22:56
>>426
421-422 じゃないけど、Python 学習をかねて調べてみました。

class Foo:
def f(self): return "I'm of class"

foo = Foo()
foo.f() => "I'm of class"
bar = Foo()
bar.f() => "I'm of class"

def newF(): return "I'm *not" of class"

foo.f = newF
foo.f() => "I'm *not* of class"
bar.f() => "I'm of class"

def anotherF(self): return "I'm *also* of class"
Foo.f = antoherF

foo.f() => "I'm *not* of class"
bar.f() => "I'm *also* of class"


次ページ
続きを表示
1を表示
最新レス表示
スレッドの検索
類似スレ一覧
話題のニュース
おまかせリスト
▼オプションを表示
暇つぶし2ch

5404日前に更新/368 KB
担当:undef