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

print "hello world" 多好

  •  
  •   Gem · 2017-01-04 15:24:34 +08:00 · 2744 次点击
    这是一个创建于 2671 天前的主题,其中的信息可能已经有所发展或是发生改变。
    python3 其他改进还好,就是这个 print ,设计成函数 print("hello world"),感觉不简洁了。
    10 条回复    2017-01-05 16:54:35 +08:00
    fatestigma
        1
    fatestigma  
       2017-01-04 15:44:20 +08:00
    恩。一开始我也这么觉得。但是习惯了也还好。
    你可以看看几个讨论:
    https://www.reddit.com/r/Python/comments/45vok2/why_did_python_3_change_the_print_syntax/
    https://news.ycombinator.com/item?id=10822804
    官方基本在 3.0 的介绍里都会把「 Print Is A Function 」放第一个。
    guyskk
        2
    guyskk  
       2017-01-04 16:25:03 +08:00 via Android
    设计成函数方便传参数控制输出格式,也可以 from pprint import ppring as print 这样,总结起来就是增加灵活性减少暗坑
    leavic
        3
    leavic  
       2017-01-04 17:08:21 +08:00
    等你要把 print 作为回调函数的时候你就知道这个改进有多好了
    msg7086
        4
    msg7086  
       2017-01-05 06:53:57 +08:00
    你要简洁为什么还要用 Python ?
    Gem
        5
    Gem  
    OP
       2017-01-05 07:07:58 +08:00
    @msg7086 OK, let's ruby... and on rails!
    nicegoing
        6
    nicegoing  
       2017-01-05 09:32:34 +08:00
    IDE 不帮你干好了吗?自动补全。
    littleshy
        7
    littleshy  
       2017-01-05 09:52:39 +08:00
    感觉还是函数调用不需要括号爽。
    zjyjer
        8
    zjyjer  
       2017-01-05 13:38:50 +08:00
    @littleshy Haskell 大法好
    littleshy
        9
    littleshy  
       2017-01-05 16:25:56 +08:00
    @zjyjer Ruby, Elixir, F# 都不用呀。
    ferstar
        10
    ferstar  
       2017-01-05 16:54:35 +08:00
    习惯就好, 反正为了 Python3 可以无视 u"哈哈"这一条打死我都要上船
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3271 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 11:44 · PVG 19:44 · LAX 04:44 · JFK 07:44
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.