0
私はのpythonの記述子を試していましたが、それが呼び出されているかどうかを確認するためにを取得しました。Pythonの記述子 "__get__"が期待通りに呼び出されなかったのはなぜですか?
私は、次のを持っている:
"""This is the help document"""
class c1(object):
"""This is my __doc__"""
def __get__(s,inst,owner):
print "__get__"
def __init__(s):
print "__init__"
s.name='abc'
class d(object):
def __init__(s):
s.c=c1()
d1=d()
d1.c
print d1.c.name
私はそれが機能を得る呼び出すことを期待しています。しかし、それは、実際の出力は、なぜ私の「取得」機能は「D1」のインスタンス所有者によって
__init__
abc
と呼ばれていなかったのですか?
ありがとうございます!