8

Python 类的析构函数的一些疑问,析构到底是和类绑定一起释放还是类释放以后调用的函...

 3 years ago
source link: https://www.v2ex.com/t/799633
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

V2EX  ›  Python

Python 类的析构函数的一些疑问,析构到底是和类绑定一起释放还是类释放以后调用的函数。

  paniford · 15 小时 18 分钟前 · 379 次点击

在对 python 实现代码拼接的时候将用户的代码拼接成一个类,其中析构函数可能会用来释放一些资源,不确定如果析构函数在调用的时候出错的话,资源会不会被释放。我也手动调用了 gc,这个过程中,看了网上一些说明,没搞明白析构函数是释放完类以后调用了析构函数还是调用完析构释放了整个包含析构的类?


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK