未加星标

Which Version of Python Should I Use?

字体大小 | |
[开发(python) 所属分类 开发(python) | 发布者 店小二05 | 时间 2017 | 作者 红领巾 ] 0人收藏点击收藏

Which version of python should I use? Now, that’s a loaded question. While the answer is simple, the explanation is more complicated.

tl;dr Use the latest version of Python 3 . Use the CPython implementation. Use venv or virtualenv to manage multiple installations. Use PyCharm or PyDev as the IDE. Which Version?

Python 2 and Python 3 are actually slightly different languages. The differences go deeper than just print statements. The What’s New in Python page on the official doc site lists all the gory details, and decent articles showcasing differences can be found here , here , and here . Although Python 3 is newer, Python 2 remains prevalent. Most popular packages use Python packaging tools to support both versions. At the time of writing this article, the currentversions of Python are 3.6 and 2.7 .

The Python Wiki makes it clear that Python 3 is the better choice :

Python 2.x is legacy, Python 3.x is the present and future of the language

Furthermore, Python 2 will reach end-of-life in 2020 . The Python team will continue to provide bug fixes for 2.7 until 2020 ( PEP 373 ), but there will be no new language features and no 2.8 ( PEP 404 ). (Originally, end-of-life was planned for 2015, but it was pushed back by 5 years.) There is even a Python 2.7 Countdown clock online.

Which Implementation?

In purest terms, “Python” isa language specification.An implementation provides the language processing tools (compiler, interpreter, etc.) to run Python programs. The Hitchhiker’s Guide to Python has a great article entitled Picking an Interpreter that provides a good summaryof available interpreters. Others are listed on python.org and the Python Wiki . The table below provides a quick overview of the big ones.

Implementation Points CPython most widely used implementation the reference implementation has the most libraries and support implemented in C supports Python 2 and 3 PyPy much faster than CPython much more memory efficient implemented in RPython supports Python 2 and 3 Jython implemented in Java runs on the JVM supports Python 2 only a sandbox for Python 3 no project updates since May 2015 IronPython implemented for .NET lets Python libs call .NET and vice versa supports Python 2 Python for .NET integrates CPython with .NET/Mono runtime supports Python 2 and 3 Stackless Python branch of CPython with real threading MicroPython optimized for microcontrollers uses a subset of the standard library

Unless you have a very specific reason, just use CPython . In fact, most people are referring to CPython when they say “Python.” CPython has the most compatibility, the widest package library, and the richest support.

Managing Installations

The simplest way to install Python is to install it “globally” for the system. In fact, some operating systems like macOS and Ubuntu have Python pre-installed. However, global installation has limitations:

You may want to develop packages for both versions 2 and 3. You may not have permissions to add new packages globally. Different projects may require different versions of packages.

These problems can be solved by using “virtual” environments. A virtual environment is like a local Python installation with a specific package set. For example, I have created virtual environments for Python as part of Jenkins build jobs, since I did not have permission to install special automation packages globally on the Jenkins slaves.

The standard virtual environment tool for Python is venv , which has been packaged with (C)Python since 3.3. ( venv

本文开发(python)相关术语:python基础教程 python多线程 web开发工程师 软件开发工程师 软件开发流程

主题: PythonJVMUbuntuJava
分页:12
转载请注明
本文标题:Which Version of Python Should I Use?
本站链接:http://www.codesec.net/view/531307.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 开发(python) | 评论(0) | 阅读(18)