why weakref?

a = classa()  # a is an class

b = a

a = None

what is the value of b?  (answer is  address of  instance a).

if you run the code , you will know what i want to talk about.  yeah,  we can use weakref to resolve this problem.

and clean python object completely. 

we replace  b = a of  b = weakref.ref(a)

Leave a comment

0 Comments.

Leave a Reply


[ Ctrl + Enter ]

click to change验证码

无觅相关文章插件