8000 Python 2 vs Python 3 · mostlybob/python-guide@45e106d · GitHub
[go: up one dir, main page]

Skip to content

Commit 45e106d

Browse files
author
Kenneth Reitz
committed
Python 2 vs Python 3
1 parent 4492619 commit 45e106d

File tree

1 file changed

+50
-11
lines changed

1 file changed

+50
-11
lines changed

docs/starting/which-python.rst

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,62 @@ Picking an Interpreter
33

44
.. _which-python:
55

6-
Today (Python 3)
7-
~~~~~~~~~~~~~~~~
6+
The State of Python (2 vs 3)
7+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
88

9-
If you're choosing a Python interpreter to use, I recommend you use the
10-
newest Python 3.x, since every version brings new and improved standard
11-
library modules, security and bug fixes.
9+
When choosing a Python interpreter, one looming question is always present:
10+
"Should I choose Python 2 or Python 3"? The answer is not as obvious as
11+
one might thing.
1212

13-
Only use Python 2 if you have a strong reason to, such as a Python 2
14-
exclusive library which has no adequate, Python 3 ready alternative. Use
15-
`Can I Use Python 3? <https://caniusepython3.com/>` to check if this is
16-
the case.
1713

18-
Python 2.x is legacy, Python 3.x is the present and future of the language
14+
The basic gist of the state of things is as follows:
15+
16+
1. Python 2.7 has been the standard for Python developers for a *long* time.
17+
2. Python 3.x intrudced major controvercial changes to the language, which many developers are unhappy with.
18+
3. Python 2.7 will receive security updates for a long while.
19+
4. Python 2.x is continually evolving, like Python 2 did in years past.
20+
21+
So, you can now see why this is not such an easy decision.
22+
23+
24+
Recommendations
25+
~~~~~~~~~~~~~~~
26+
27+
I'll be blunt:
28+
29+
30+
**Use Python 3 if...**
31+
32+
- You don't care.
33+
- You love Python 3.
34+
- You are indifferent towards 2 vs 3.
35+
- You don't know which one to use.
36+
- You embrace change.
37+
38+
**Use Python 2 if...**
39+
40+
- You love Python 2 and are saddened by the future being Python 3.
41+
- The statbility requirements of your software would be improved by a language and runtime that never changes.
42+
- Software that you depend on requires it.
43+
44+
45+
So.... 3?
46+
~~~~~~~~~
47+
48+
If you're choosing a Python interpreter to use, and aren't opinionated, then I
49+
recommend you use the newest Python 3.x, since every version brings new and
50+
improved standard library modules, security and bug fixes. Progress is progress.
51+
52+
Given such, only use Python 2 if you have a strong reason to, such as a Python 2
53+
exclusive library which has no adequate Python 3 ready alternative, or you
54+
(like me) absolutely love and are inspired by Python 2.
55+
56+
Check out `Can I Use Python 3? <https://caniusepython3.com/>` to see if any
57+
software you're depending on will block your adoption of Python 3.
1958

2059
`Further Reading <http://wiki.python.org/moin/Python2orPython3>`_
2160

22-
It is possible to `write code that works on Python 2.6, 2.7 and 3.3
61+
It is possible to `write code that works on Python 2.6, 2.7, and 3.3
2362
<http://lucumr.pocoo.org/2013/5/21/porting-to-python-3-redux/>`_. This
2463
ranges from trivial to hard depending upon the kind of software
2564
you are writing; if you're a beginner there are far more important things to

0 commit comments

Comments
 (0)
0