__del__方法 [英] __del__ methods

查看:90
本文介绍了__del__方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个课,我需要在它死后做一些最终确定。我知道我可以使用__del__方法,但我似乎记得它

阻止了垃圾收集。是这样的吗?


(请记住,我的代码旨在与python 2.3兼容

python 2.5)

I have a class that I need to do some finalization on when it dies. I
know I can use the __del__ method, but I seem to recall that it
impedes garbage collection. Is this the case?

(keep in mind that my code aims to be compatible with python 2.3 to
python 2.5)

推荐答案

周五,2008年7月18日11:31:20 -0700,Jason Baker写道:
On Fri, 18 Jul 2008 11:31:20 -0700, Jason Baker wrote:

我有一个类,我需要在它死后做一些最终确定。我知道我可以使用__del__方法,但我似乎记得它

阻止了垃圾收集。是这样的吗?
I have a class that I need to do some finalization on when it dies. I
know I can use the __del__ method, but I seem to recall that it
impedes garbage collection. Is this the case?



`__del __()`不是确定性的析构函数。所以忘掉可靠的

自动清理。通过显式调用`close()`

方法或类似的方法自己动手。


Ciao,

Marc''BlackJack''Rintsch

`__del__()` is not a deterministic destructor. So forget about reliable
automatic clean up. Do it yourself with an explicit call to a `close()`
method or something like that.

Ciao,
Marc ''BlackJack'' Rintsch


7月18日,2:10 * pm,Marc''BlackJack''Rintsch< bj _... @ gmx.netwrote:
On Jul 18, 2:10*pm, Marc ''BlackJack'' Rintsch <bj_...@gmx.netwrote:

周五,2008年7月18日11:31:20 -0700,Jason Baker写道:
On Fri, 18 Jul 2008 11:31:20 -0700, Jason Baker wrote:

我有一个课,我需要在它死后做一些最终确定。 *我

知道我可以使用__del__方法,但我似乎记得它

阻止了垃圾收集。这是这样的吗?
I have a class that I need to do some finalization on when it dies. *I
know I can use the __del__ method, but I seem to recall that it
impedes garbage collection. *Is this the case?



`__del __()`不是确定性的析构函数。 *所以忘了可靠

自动清理。 *通过显式调用`close()`

方法或类似方法自行完成。


Ciao,

* * * * Marc''BlackJack''Rintsch


`__del__()` is not a deterministic destructor. *So forget about reliable
automatic clean up. *Do it yourself with an explicit call to a `close()`
method or something like that.

Ciao,
* * * * Marc ''BlackJack'' Rintsch



我不一定需要确定性清理。我打算做

类似于close()方法。但是我只想让

确保没有任何东西在裂缝之间滑落。 :)

I don''t necessarily need deterministic cleanup. And I plan on doing
something like a close() method as well. But I''d just like to make
sure nothing slips between the cracks. :)


2008年7月18日星期五12:26:35 -0700,Jason Baker写道:
On Fri, 18 Jul 2008 12:26:35 -0700, Jason Baker wrote:

我不一定需要确定性清理。我打算做

类似于close()方法。但是我只想让

确保没有任何东西在裂缝之间滑落。 :)
I don''t necessarily need deterministic cleanup. And I plan on doing
something like a close() method as well. But I''d just like to make
sure nothing slips between the cracks. :)



`__del __()`并不保证*会被调用*,所以不能确定

没有任何东西在裂缝之间滑落。


Ciao,

Marc''BlackJack''Rintsch

`__del__()` isn''t guaranteed to be called *at all*, so can''t make sure
nothing slips between the cracks with it.

Ciao,
Marc ''BlackJack'' Rintsch


这篇关于__del__方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆