는 클래스의 속성을 결정하는 방법은 __get__
및 __set__
여부와 (A Property
이 있습니까? Determine if given class attribute is a property or not, Python object에있어서, 단지 내 경우에는 작동되지 property
장식, 작동 보인다처럼.클래스 속성이 Property인지 확인 하시겠습니까?
class Property(object):
_value = None
def __get__(self, instance, owner):
return self._value
def __set__(self, instance, value):
self._value = value * 2
class A(object):
b = Property()
>>> a = A()
>>> type(A.p)
<type 'NoneType'>
>>> type(a.p)
<type 'NoneType'>
올바른 용어는 '설명자'입니다. [descriptor HOWTO] (https://docs.python.org/2/howto/descriptor.html) –