top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

What is the future Python 2 or Python 3?

+3 votes
103 views

The http://www.python.org site says that the future is Python 3, yet whenever I try something new in Python, such as Tkinter, everything seems to default to Python 2.

By this I mean that, whenever I find that I need to install another package, it shows up as Python 2 unless I explicitly specify Python 3.

What's the deal? If I want to make a distributable software package, should it be 2 or 3?

posted Dec 27, 2013 by Deepak Dasgupta

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button
The future is indeed Python 3. The problem with the future is that it's  not here yet.

2 Answers

+1 vote

The past is Python 2; the future is Python 3. The present is both Pythons, running in parallel; if you're lucky, that's 2.7 and the latest 3.x, though not everyone has that luxury.

For new code, aim for Python 3 unless you have a good reason to go for Python 2. Most Linux distributions come with Python 2 under the name "python", and Python 3 under the name "python3"; stick with that and you'll be fairly safe. Or, if you can depend on your users having a recent Py3 installed, you can use the launcher packaged with 3.3 and later, which can intelligently figure out version.

answer Dec 27, 2013 by Seema Siddique
+1 vote

Always use 3 unless you absolutely have to use 2. Python 3 is not a shiny new thing. It is *five* years old at this point and is soon to have its *fifth* significant release. Python 2.6 is EOL, and there will not be a 2.8.

However, people have stayed with Python 2 for various reasons, and unfortunately, many of those people haven't even made an effort to migrate until the last year or so.

Most of the major third-party libraries these days are either 3.x compatible or have 3.x-compatible replacements, though.

answer Dec 27, 2013 by Seema Siddique
Similar Questions
+2 votes

I have two Questions:

  1. Could Python 3.2, when compiled against OpenSSL 1.0.0j, be affected by the poodle bug? https://www.openssl.org/~bodo/ssl-poodle.pdf

  2. If yes - are the following OpenSSL versions approved for use with Python 3.2:
    OpenSSL 0.9.8zf
    OpenSSL 1.0.0r
    OpenSSL 1.0.1m
    OpenSSL 1.0.2a

+2 votes

I am working on drawing map from shape file in Python 3.2 basemap. But, the longitude values at the bottom axis are only shown partially. Also, all latitude values are missing.

Here is my python code.

import shapefile as sf
import sys
import numpy as np
import matplotlib.pylab as plt
from mpl_toolkits.basemap import Basemap

 map = Basemap(projection='stere', lon_0=-106.4, lat_0= 31.9, lat_ts = 31.9, 
 llcrnrlat=31.7, urcrnrlat= 31.85, 
 llcrnrlon=-106.5 , urcrnrlon= -106.1, 
 rsphere=6371200., resolution='l', area_thresh=1000)

 plt.figure(num=None, figsize=(10, 8), dpi=80, facecolor='w', edgecolor='k')

parallels = np.arange(31.7, 31.85, 0.25)

map.drawparallels(parallels, labels=[0, 0, 0, 1] , fontsize=10, labelstyle='+/-', dashes=[2, 2])

meridians = np.arange (-106.5, -106.1, 0.25)

map.drawmeridians(meridians, labels=[0, 0, 0, 1], fontsize=10, labelstyle='+/-' , dashes=[2, 2])

No matter how I changed the labels, the latitude/longitude legend values are still missing.

+3 votes

Here is what I have tried:

root@secure [~]# which python3
/usr/bin/python3

root@secure [~]# which pip
/usr/bin/pip

root@secure [~]# yum install pip3
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.secrel.com.br
 * epel: mirror.imt-systems.com
 * extras: centos.secrel.com.br
 * remi: mirror5.layerjet.com
 * updates: mirrors.ucr.ac.cr
Setting up Install Process
No package pip3 available.
Error: Nothing to do
0 votes

I have a Python script that I wrote to support a project that I work on (that runs primarily on Unix OSes). Given its support role in this package, this script should not introduce any other dependencies. As a result, I wrote the script in Python 2, since every Linux currently ships with 2.4--2.7 as its system Python (RHEL 5, still popular in my field, ships with 2.4).
However, Ive heard news that Ubuntu is migrating to Python 3 soon (next release??), and thats a platform we actively try to support due to its popularity. Ive tried writing the code to support both 2 and 3 as much as possible, but with priority put on supporting 2.4 over 3.
Now that Python 3-compatibility is about to become more important, Im looking for a way to catch and store exceptions in a compatible way. Because Python 2.4 and 2.5 dont support the except Exception as err:
syntax, Ive used except Exception, err:
Is there any way of getting this effect in a way compatible with Py2.4 and 3.x? Of course I could duplicate every module with 2to3 and do sys.version_info-conditional imports, but Id rather avoid duplicating all of the code if possible.

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...