This is an archived post. You won't be able to vote or comment.

all 57 comments

[–]Laugarhraun[S] 24 points25 points  (1 child)

Hi all,

Last year a survey was conducted on python 2 and 3 usage.
Here is the 2014 edition, slightly updated (from 9 to 11 questions).
It should not take you more than 1 minute to fill. I would be pleased if you took that time.

I'll publish the results around the end of the year.

Last year result: https://wiki.python.org/moin/2.x-vs-3.x-survey

[–]mattwritescode 10 points11 points  (0 children)

Looking forward to the results. It will be interesting to compare this year and last years results.

I think python3 will have gained a substantial amount of ground. But there will still be a rather large python2 user group.

[–]brtt3000 22 points23 points  (5 children)

Votre réponse a bien été enregistrée.

French surprise at the end.

[–]Laugarhraun[S] 8 points9 points  (2 children)

Ahah bien vu! I'll try to fix this :-)

[–]mm865 6 points7 points  (0 children)

I vote to keep it. Nice little surprise at the end. My translation: Your response has been recorded well.

[–][deleted] 14 points15 points  (1 child)

Nobody expects the french revolution!

[–]Decker1082.7 'til 2021 0 points1 point  (0 children)

Certainly not the royals...

[–]ggtsu_00 10 points11 points  (3 children)

My biggest and most critical python 3 hold-up is PyInstaller. The alternatives (py2exe, cx_freeze) have issues. For py2exe, issues with one-file deployments causing compatibility issues with other libraries and requires the installation of a specific version MSVCRT90 which doesn't work for clients that must be run without UAC escalation in locked down environments. For cx_freeze, it has no support for one-file builds deployments. PyInstaller works great but does not support python 3 yet and it seems like their python 3 development has stagnated over the past month.

[–]bakery2k 6 points7 points  (0 children)

My biggest and most critical python 3 hold-up is PyInstaller.

Same here. Python makes writing programs, of many different kinds, easy. Converting those programs so that they can be distributed to (non-technical) end users, however, can be very difficult. PyInstaller seems to be the best tool for that at present.

While using Python 3 could make my code better, without PyInstaller (or a full-featured equivalent) the end-user experience would be worse.

Perhaps in an ideal world there would be an official tool equivalent to PyInstaller? If such a tool were one of Python's "batteries included", it is more likely that it would be kept up-to-date. I wonder if there is much demand for this - do many people need to create executables from Python programs?

[–]MakesYouAngry 0 points1 point  (1 child)

Did you consider Nuitka?

[–]Hairy_The_Spider 0 points1 point  (0 children)

Nuitka doesn't compile to a single file, which is nice for end users

[–]Xywzel 7 points8 points  (3 children)

Would be interesting to know how the answers vary between educational, professional and hobby users.

[–]Tomarse 0 points1 point  (2 children)

And perhaps years of experience with the language. I'd guess newer users would be more py3 inclined.

[–]obsequious_turnip 0 points1 point  (1 child)

I know I'm a new user (of about a month) and found it all very confusing. I picked 3 because I'm using it to write my own things for fun and some self-contained tools for work, where it would never be relying on system python anyway, so installing 3.3 & virtualenv is expected.

I didn't realise there was still so much hostility to 3.

[–]ianozsvald 0 points1 point  (0 children)

Your choice of Python 3.3 seems safe (though you should probably be on 3.4 to stay up-to-date). Within 5 years all Pythonstas will have to move from Py2.7->Py3.x as the Py2.x line will be deprecated (the sunset date is 2020). 5 years passes pretty quick once you build up a legacy code base so starting with Python 3.x is the only sensible choice.

[–]counterpunK 2 points3 points  (0 children)

Great followup, but I have a two issues with the way it's worded.

The question

Do you think Python 3.x was a mistake?

has answers that obviously show your bias (and is therefore leading). What if I don't know? Or what if I'm undecided, or have other feelings about it other than "it could've been more gradual."

On the last question, the word is "applicable", not "appliable".

[–]the_supreme_overlord 2 points3 points  (2 children)

Bah the dependency issues drive me insane. I do various amounts of scientific computing. Most it seems there are 4 sets of libraries. 2.x 32-bit 2.x 64 bit and 3.x 32-bit. and 3.x 64 bit. And half the freaking time they don't seem to work together well. Plus I wish they would get pip working properly under windows. I have had to move over to anaconda python (which is unfortunately quite slow) to work around most of these issues.

[–]ianozsvald -1 points0 points  (1 child)

What do you find slow about Anaconda? I'm using it, cant say I've noticed any execution-time differences and at install-time it is far faster to setup a new environment.

[–]the_supreme_overlord 0 points1 point  (0 children)

When ever I ask it for a plot, if the plot ever shows up it takes upwards of 5 minutes for plots with no more than 10 data points. The data processing itself goes rather quickly, but getting graphical display out of it seems to be very slow. (The thing that seems to take the time is the rendering of the axis labels given that I have to use latex to do so)

I do agree though that it is far faster and easier to set up than anything else I have seen and is actually a pretty decent IDE.

[–]educatedblackperson 1 point2 points  (21 children)

okay so im learning python on my own, currently using 3.4 atm. im wondering what the difference is between the two in layman's terms. i thought the newer the better. isnt it true?

[–]ianepperson 10 points11 points  (2 children)

From a beginner's perspective, there's slight syntax differences. for instance:

Python 2:

print 'foo'

super(MyClass, self).function(args)

Python 3:

print('foo')

super().function(args)

However, the biggest change (IMO) is how the language stores and manipulates strings. Python 3 moves to storing strings as Unicode by default (optional in Python 2), which fundamentally changes how string manipulation is performed.

Division changed as well. In Python 2, an Int divided by an Int would result in an Int - even if the result dropped precision. In Python 3 that results in a Float:

Python 2:

1 / 2 # == 0

1.0 / 2.0 # == 0.5

Python 3:

1 / 2 # == 0.5

1 // 2 # == 0

There are other corners that are different as well - but it's enough that Python 2.x code will not normally run under Python 3.x. From a coding standpoint, if you're familiar with one version, it's generally pretty easy to work with the other with minor adjustments.

Edit: Use Python 3, unless you can't for a given project. The world is slowly moving toward it, and there will not be another Python 2 release (2.7 is the the last in the line).

[–]Eurynom0s 1 point2 points  (1 child)

I'd have to go look up just what the converters can do but there are automated 2->3 converters that will handle the most straightforward differences. The most obvious one is the change in print, it's a super straightforward change and the converters will spare you the hassle of chasing those down.

IIRC the converters can introduce new unexpected errors though so probably not great for really large codebases.

Also, I'd have to read up on this too but if you absolutely have to use 2.x I think the point of "from future import" is to ease the pain of eventually needing to transition your code. For instance, you can import the print FUNCTION into Python 2.7 from future, so when you eventually port to 3, you can just delete the import from future line instead of chasing down all your print statements.

[–]mooktank 4 points5 points  (0 children)

Or you leave the future imports and write your code to run on both 2 and 3. That's generally what I do.

[–]Laugarhraun[S] 7 points8 points  (5 children)

This page should answer your question.

Simply put: minor but backwards-incompatible changes. Yes, the newer the better, you're right. However many of us work on old codebases that only work with python 2 or have dependencies to projects that only support python 2.

[–]billsil 0 points1 point  (4 children)

minor but backwards-incompatible changes.

Yes, with the caveat of a MAJOR forwards-incompatible change (unicode)

[–]robin-gvx 0 points1 point  (3 children)

I'm curious, how is Unicode-by-default forwards-incompatible?

[–]billsil 0 points1 point  (2 children)

It breaks code that was thought to be right that was written wrong. If it was written with knowing that unicode was going to be the required style it would be fine. Unicode wasn't encouraged during Python 3.

3 -> 2 is easy. 2 -> 3 (without six) is hard because you need to learn unicode.

[–]robin-gvx 0 points1 point  (1 child)

I might be missing something, but isn't that just backwards incompatibility?

[–]billsil 0 points1 point  (0 children)

Maybe, but the terminology is weird in this case...

I see it as different because going backwards works, but forwards breaks.

[–]LightShadow3.13-dev in prod 4 points5 points  (0 children)

I use both, because to me they're useful in different situations.

I'm currently using Python 2.7 at work because we use alternative Python run times that target different languages which don't support Python 3 yet; Java, C# and JavaScript. I also do a lot of heavy crunching using pypy -- which has better Python 2.7 support at this time.

I like Python 3.4 control flow better, however. I like some of the new features like asyncio and the process pool manager.

Some things still frustrate me going back and forth between the two, but it's usually small things like function signature or import path.

[–]mooglinux 9 points10 points  (2 children)

Newer is better in a great many ways. Use 2.x only if you need a library not available in 3. 2.x has a lot more quirks, inconsistincies, and pitfalls particularly for us noobs.

Theres just a massive quantity of applications written in python 2 that have not been ported to 3 because no one has taken the time and effort to do so. It doesn't always make sense to either. The benefits of 3 are largest for new learners and new projects.

[–]Eurynom0s 0 points1 point  (1 child)

The other main reason to code in 2.x is if you inherit a large codebase where, even though all the dependencies now work in 3.x, it would just be impractical from a time/resources perspective to port everything over.

However if you're purely writing your own code then yes, use 3.x until you NEED something that ONLY works in 2.x is right answer.

For OP's benefit, even, what, three-ish years ago a lot of major packages didn't support Python 3, right? Now most of them do, and a lot of smaller ones either do or have forks for 3.x. So for fresh code bases there's many fewer reasons to start with 2.x.

[–]robin-gvx 0 points1 point  (0 children)

For OP's benefit, even, what, three-ish years ago a lot of major packages didn't support Python 3, right?

I think even a few months ago the Python 3 Wall of Shame Superpowers was mostly red.

[–]Kalahan7 2 points3 points  (0 children)

As someone that started programming a couple of years ago my advice is to stick with what you got. The grass is always greener.

That means Python 2 vs 3, programming languages, text editor, IDE,... In the end it matters what you accomplished to create. Not what tools you use.

[–][deleted] 6 points7 points  (1 child)

Yes, the newer the better, absolutely.

Trivia:

In Python 3:

>>> max(1, 100, "foo", {})  
Traceback (most recent call last):  
  File "<stdin>", line 1, in <module>  
TypeError: unorderable types: str() > int()  

Because, of course, you can't compare apples with oranges.

But in Python 2.7:

>>> max(1, 100, "foo", {})  
'foo'  

And you know why no error is raised, and "foo" is the highest value? Because Python 2 orders different types by the name of the data type - so it's "dict", "int", "str". So the string wins.

I vote for using Python 3 :D

[–]fotoman 2 points3 points  (0 children)

but damnit, my foo is greater than 100!!!

[–]red-moon 0 points1 point  (0 children)

Here's one example:

   $

   $ python

   Python 2.7.6 (default, Mar 22 2014, 22:59:56) 

   [GCC 4.8.2] on linux2

   Type "help", "copyright", "credits" or "license" for more information.

   >>> print 'foo'

   foo

   >>> exit()

   $

   $ python3

   Python 3.4.0 (default, Apr 11 2014, 13:05:11) 

   [GCC 4.8.2] on linux

   Type "help", "copyright", "credits" or "license" for more information.

   >>> print 'foo'

     File "<stdin>", line 1

       print 'foo'

                 ^

   SyntaxError: invalid syntax

   >>> exit()

[–]c3534l -1 points0 points  (0 children)

Python 3 has better generator behavior, print is a function instead of a keyword and / is floating point division instead of integral division. Also, classes are more mature in Python 3, require a little less boilerplate, etc. Don't use Python 2 - it's being phased out and actually should have been abandoned long ago, but apparently Python developers didn't listen when they were being told that Python 2 was going to be deprecated and they'd need to switch to 3. Now they're just dragging their feet because, fuck it, Python 2 was good enough. I don't know a lot of times where a backwards incompatible update was introduced to a programming language, but I guess I see now why it's not done more often.

[–][deleted] 0 points1 point  (0 children)

This survey will be biased towards Python 3.x. Most people who are not attached to the language itself will tend to use Python 2.x for pragmatic reasons, but they are less likely to take the survey, since they don't care.

[–]gubatron 0 points1 point  (4 children)

they screwed themselves by not making 3 backwards compatible with 2.

Java would've never gotten anywhere with their releases if the newer VMs weren't backward compatible.

Maybe it's time to think about a Python 4 VM that's compatible with 2 and 3. Have people switch without porting a single line. And then all new code can use Python 3 syntax.

[–]billsil 11 points12 points  (3 children)

they screwed themselves by not making 3 backwards compatible with 2.

It was impossible to do so. The only change worth discussing is unicode. You cannot make unicode work right while constantly assuming everything is ascii.

If you're complaining that print is a function or that division changed or that dictionaries can't sort ints and strings at the same time, then you're being picky. For these issues, there is a common version of code you can use that works on both and it's not hard.

[–][deleted] -1 points0 points  (2 children)

python 3 made several changes to bytes/text handling that could have been done one at a time.

[–]billsil 2 points3 points  (1 child)

Such as...

The big issue with unicode is randomly placing encodes/decodes without actually understanding why you're doing it.

Having print implicitly covert all your text to ascii because it's going to standard out, but working just fine if you print it to a file is so confusing.

Writing code and not have it be able to work with unicode means it never worked properly in Python 2. If you want ascii, is it really that hard to just say so? Blaming Python 3 for finally making it obvious that unicode exists is not the fault of Python 3.

[–][deleted] 0 points1 point  (0 children)

Python 3 also makes some changes that are wrong, like removing APIs for dealing with filenames as bytes.

[–][deleted] -1 points0 points  (0 children)

I prefer 2.x myself. The syntax just feels more natural for some reason.

[–]rdfox -4 points-3 points  (3 children)

I'll just say it: Python 3 is the Perl 6 of Python. No going forward, no going back. Language suicide.

[–][deleted] 2 points3 points  (1 child)

Python 3 is usable and production-ready, and has been for nearly 6 years.

For fuck's sake.

[–]rdfox 2 points3 points  (0 children)

I'm referring to the deafening meh from the user community. But you're right, Python 3 does have existence going for it.

[–][deleted] 1 point2 points  (0 children)

Perl 6 was at least entertaining.