weakref.ref()

CODEDRAGON Development/Python

반응형



 

 

 

 

weakref.ref()

·         {weakref} 모듈의 ref() 함수입니다.

·         인자로 받은 객체 o 대한 약한 참조를 생성합니다.

·         객체가 메모리에 남아 있지 않으면 None 반환합니다.

 

 

weakref.ref(o)

 

parameter

description

o

객체

 

 

 

약한 참조로 부터 실제 객체를 참조하는 방법

생성된 약한 참조 객체에 함수형태 호출합니다.

 

약한 참조 객체 r 생성

= weakref.ref(c) 

 

약한 참조로 부터 실제 객체를 참조하는 방법약한 참조 객체에 함수형태로 호출

print (r()) 

<__main__.MyClass object at 0x00000214D8706748>

 


반응형

'Development > Python' 카테고리의 다른 글

weakref 정보 확인  (0) 2020.02.16
weakref.proxy()  (0) 2020.02.16
약한 참조 (Weak Reference)  (0) 2020.02.16
generator Expression  (0) 2020.02.16
import  (0) 2020.02.16