Is __del__ really a destructor?

前端 未结 4 734
没有蜡笔的小新
没有蜡笔的小新 2021-02-05 14:58

I do things mostly in C++, where the destructor method is really meant for destruction of an acquired resource. Recently I started with python (which is really a fun and fantast

4条回答
  •  有刺的猬
    2021-02-05 15:15

    Is del really a destructor?

    No, __del__ method is not a destructor, is just a normal method you can call whenever you want to perform any operation, but it is always called before the garbage collector destroys the object. Think of it like a clean or last will method.

提交回复
热议问题