V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
vking
V2EX  ›  Python

python 3.x中,不再有__del__ ?

  •  
  •   vking · 2013-02-27 15:02:44 +08:00 · 2985 次点击
    这是一个创建于 4048 天前的主题,其中的信息可能已经有所发展或是发生改变。
    按照http://sebug.net/paper/python/ch11s06.html的代码,在3.3中测试了一下,发现__del__没有起作用.
    4 条回复    1970-01-01 08:00:00 +08:00
    reusFork
        1
    reusFork  
       2013-02-27 15:08:34 +08:00
    __del__不保证会被调用的
    reusFork
        2
    reusFork  
       2013-02-27 15:10:02 +08:00
    不要看这本书了
    vking
        3
    vking  
    OP
       2013-02-27 15:14:51 +08:00
    @reusFork 推荐一本,一本即可.
    中文版Python3教程 怎么样?
    BOYPT
        4
    BOYPT  
       2013-02-28 09:52:06 +08:00
    如果你想要指明它的运行,你就得使用del语句,就如同我们在以前的例子中使用的那样。
    ====

    这句话的描述是错误的,见python document中加了注意框的描述:

    http://docs.python.org/3/reference/datamodel.html#object.__del__
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2855 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 14:27 · PVG 22:27 · LAX 07:27 · JFK 10:27
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.