Effective Python entry one: Know which version of Python you are using now

Source: Internet
Author: User

Entry one: Know which version of Python you are using now

In this book, the code for the primary instance is the syntax for Python3.4 (released on March 17, 2014). This book also provides some examples of Python2.7 (posted on July 3, 2010) to emphasize differences. Most of my recommendations can be applied to the popular Python runtime library: CPython, Jython, IronPython, PyPy, etc.

Many computers are preinstalled with multiple versions of the standard CPython Runtime library. However, the default Python in the command line is not clear. Python is usually an alias for python2.7, but sometimes it is also an alias for older versions, such as python2.6 or python2.5. Make clear which Python version you are using and use--version to identify it.

$ python--2.7.8

Python3 's usual name is Python3.

$ python3--3.4.2

You can also figure out the Python version of the runtime you are using by detecting the values in the SYS included module:

Import SYS Print (Sys.version_info) Print (sys.version)>>>sys.version_info (Major=3, minor=4, micro=2, releaselevel= ' final ', serial=0)3.4.2 (default, OCT, 17:52:174.2.1 Compatible Apple LLVM 6.0 (clang-600.0.51)]

Python 2 and Python 3 are all maintained by the Python community. In addition to bug fixes, security improvements and the ease of reverse porting from Python2 to Python3, Python2 's development efforts have been frozen. The presence of help tools, such as 2to3 and six, makes it easier to accept Python3 's forward development.

New features and improvements that are constantly added in Python3 are no longer added to Python2. In writing this book, most of the main Python open source libraries are already compatible with Python3. I strongly encourage you to use Python3 in the next project.

Think about it and write it down.
    • There are two major Python versions that are still active: Python 2 and Python 3;
    • There are several popular Python runtime libraries: CPython, Jython, IronPython, pypy, etc.;
    • Make sure that Python is the version of Python that you expect to run on the command line of your system;
    • In your next project, Python3 is preferred because it is the main focus of the Python community.
Reprint Annotated Source

Original (English): Effective Python, item 1

(Chinese): http://www.cnblogs.com/reanote/p/effective_python_item_1

Note (hint): Copyright belongs to the original author all, such as infringe your copyright, please email contact me, I will be notified, as soon as possible delete!

Effective Python entry one: Know which version of Python you are using now

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.