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

最近用 python3.6 写了个爬虫 package, 是否要考虑兼容 3.6 以下的版本呢?

  •  
  •   waibunleung · 2019-06-22 16:56:19 +08:00 · 2924 次点击
    这是一个创建于 1763 天前的主题,其中的信息可能已经有所发展或是发生改变。

    最近跟一个外国小哥合作写了个 python 的爬虫,我们两个的意见在兼容性这一块出了分歧。
    项目是用 python3.6 写的,但是我想兼容到 python3.0,理由是考虑比较多的项目可能是用旧的 python 版本写的,升级的话会有很多未知问题,并且 python 版本升级可能要考虑很多东西。 小哥的选择是兼容到 3.6 就 ok 了,因为程序是向前发展的,它总会追求新的语法和更方便易用。
    他的原话: "Yes I understand what you mean, but you cannot always please everybody, Python 2 users wont be able to use it for example only some people some of the time! Python is a language that always looks forward to new syntax and code design is essential to understanding the code and adding to it so for me the trade off is too big"

    大家觉得应该兼容到 python3.0 还是到 python3.6 就好了?

    第 1 条附言  ·  2019-06-22 18:08:58 +08:00
    行吧看了很多评论,选择直接只兼容到 python3.6 了
    23 条回复    2019-06-25 15:20:02 +08:00
    find456789
        1
    find456789  
       2019-06-22 17:01:31 +08:00
    他是对的
    dcalsky
        2
    dcalsky  
       2019-06-22 17:02:33 +08:00
    用 3.5 的 async/await 了吗?如果用了,只能考虑兼容到 3.5。如果没用,再考虑 3.0 的事情。
    heww
        3
    heww  
       2019-06-22 17:02:53 +08:00
    我最近写了个东西,用的 Python 3,但应该在 Python 2 下也能用。

    后面要用到的一个标准库从 Python 3.6 才开始有,果断在 setup.py 里去掉 Python 2, Python 3.6 以下的支持。
    iyaozhen
        4
    iyaozhen  
       2019-06-22 17:05:02 +08:00 via Android
    3.x 的话都差不多,如果用了 await 啥的,只兼容到 3.5 就行。用 3.x 的升级也比较勤快

    2.x 还是得狠心抛弃
    aquariumm
        5
    aquariumm  
       2019-06-22 17:05:28 +08:00 via Android
    看你这个工具给谁用的
    Windows 现在还能兼容 win98 的应用程序,但是给公司或者自己用就没必要了,只维护最新版本第一效率高代码少,第二运行效率高
    msg7086
        6
    msg7086  
       2019-06-22 17:06:03 +08:00
    你想想,是应该让旧版本的代码升级成支持新版的,还是应该让新版本的代码自残去兼容旧版的。
    loading
        7
    loading  
       2019-06-22 17:08:13 +08:00
    建议先专注核心功能,如果有更多的兼容需求的 issues 再说。
    waibunleung
        8
    waibunleung  
    OP
       2019-06-22 17:08:21 +08:00
    @msg7086 现在就是纠结和个问题啊, 小哥是前者, 我是后者
    waibunleung
        9
    waibunleung  
    OP
       2019-06-22 17:09:22 +08:00
    @loading 核心功能已经完善了我只是不想把地址发出来,以免说我推广,现在很多地方用了 3.6 才支持的 f strings
    Kyle18Tang
        10
    Kyle18Tang  
       2019-06-22 17:24:32 +08:00 via Android
    支持外国小哥,你肯定不能满足所有人。
    Trim21
        11
    Trim21  
       2019-06-22 17:32:42 +08:00
    >3.0,<3.6 的 python 升级到 3.6 比 3.6 要兼容到 3.0 简单多了吧……
    godlovesxcjtest
        12
    godlovesxcjtest  
       2019-06-22 17:34:20 +08:00 via Android
    他是对的
    qcts33
        13
    qcts33  
       2019-06-22 17:48:32 +08:00   ❤️ 2
    我看一般都是支持 3.4 以上的,似乎早期的 py3 的 API 还没稳定?
    xiaket
        14
    xiaket  
       2019-06-22 17:49:09 +08:00
    Python 3.6, 其余的 Python3 可以忽略.
    roronoaws
        15
    roronoaws  
       2019-06-22 17:50:23 +08:00 via Android
    他说的好有道理啊
    dongxiao
        16
    dongxiao  
       2019-06-22 17:57:40 +08:00
    首先看需求,
    然后看自己时间是否宽裕吧
    nooper
        17
    nooper  
       2019-06-22 18:04:31 +08:00   ❤️ 1
    我现在还在写 2.3 呢,可以考虑兼容 2.3-2.4.2.2.6 吗
    janxin
        18
    janxin  
       2019-06-22 18:05:13 +08:00
    兼容 3.0,不至于吧....
    3.5+就差不多了,最多 3.4+。主要是兼容到 3.5 成本并不那么高,除了非常好用的 f-string,其他的改变并不是特别多。3.4 之前主要是历史太久了,改变也挺多的,实在没什么必要兼容。即便是 3.4,如果有 aio 的东西改起来就比较麻烦了。而且很多老旧 Linux 系统,比如 Ubuntu 14,内置 Python3 就是 3.4 版本的,再早的系统都不提供支持了,也就无所谓了。
    waibunleung
        19
    waibunleung  
    OP
       2019-06-22 18:10:17 +08:00
    @nooper 你是来黑我的吗
    Takamine
        20
    Takamine  
       2019-06-22 22:56:55 +08:00
    对于 Py,我觉得那个老哥说的没错。
    Py2 和 Py3 是两门语言,Py3.x 以后又是开始不同分支。:doge:
    msg7086
        21
    msg7086  
       2019-06-23 02:29:06 +08:00 via Android
    @janxin 14.04 都已经 eol 了吧…
    iszero
        22
    iszero  
       2019-06-23 09:02:10 +08:00 via Android
    没必要向下兼容,包袱太重了
    zkqiang
        23
    zkqiang  
       2019-06-25 15:20:02 +08:00
    如果是开源项目真没必要... 发电还搞这么累
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2741 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 12:54 · PVG 20:54 · LAX 05:54 · JFK 08:54
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.