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
leyle
V2EX  ›  Python

python3 中支持值类型,有些时候确实方便

  •  
  •   leyle · 2018-11-03 23:52:19 +08:00 · 2192 次点击
    这是一个创建于 1972 天前的主题,其中的信息可能已经有所发展或是发生改变。
    特别是用别人的包的时候,指定一下类型,ide 在联想时,就很方便了,提高了码代码的效率。
    推荐大家也尝试下。

    这种需要的时候,就有那个功能能够满足,不需要时,也不会打扰,确实美滋滋。
    第 1 条附言  ·  2018-11-04 22:06:50 +08:00
    嗯,就是 PEP484 说的内容。
    [PEP 484 -- Type Hints | Python.org]
    https://www.python.org/dev/peps/pep-0484/
    6 条回复    2018-11-05 10:37:18 +08:00
    PythonAnswer
        1
    PythonAnswer  
       2018-11-04 00:12:45 +08:00 via iPhone
    别人发布包的时候,如果有写,的确是美滋滋。
    cyspy
        2
    cyspy  
       2018-11-04 01:03:46 +08:00
    就像很多语言引入了 var 和 val,真正需要注明类型的情况并不是绝大多数,同时 duck type 又避免了静态语言一些写起来麻烦的地方。
    congeec
        3
    congeec  
       2018-11-04 06:45:03 +08:00
    值类型? value type?
    你说的是 type annotation 和 gradual typing 吧
    ltoddy
        4
    ltoddy  
       2018-11-04 11:52:30 +08:00   ❤️ 1
    PEP 484 type hints?
    atcdef
        5
    atcdef  
       2018-11-04 21:34:10 +08:00
    类型标注?我也喜欢用,这样方便 ide 自动提示,挺好的。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3400 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 10:39 · PVG 18:39 · LAX 03:39 · JFK 06:39
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.