는 다음과 같은 코드를 생각해Weakref 및 __slots__
from weakref import ref
class Klass(object):
# __slots__ = ['foo']
def __init__(self):
self.foo = 'bar'
k = Klass()
r = ref(k)
작동을하지만 난 __slots__
의 주석을 해제 할 때 파이썬 2.6에서 TypeError: "cannot create weak reference to 'Klass' object"
함께 나누기.
이것이 파이썬과 __slots__
의 고유 한 제한 사항이거나 버그 일 경우 알려주십시오. 어떻게 해결할 수 있을까요? __slots__
을 정의하는 각 인스턴스에 대한 __weakref__
변수없이