python 2.x or 3.x [closed] - python

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Since there is a python 3.x, why don't we use it?
Why do we still use 2.x?What's the difference?

Python 2.6 and 2.7 have been written to ease the transition to Python 3.
It will take some more time to port the more complex packages (i.e. those with many dependencies, or libraries written in C).
So if you are starting new projects, and all the libraries you need are there, it makes sense to start with 3.1. One of the more welcome changes is the handling of Unicode strings by default - it will prevent a lot of bugs.
But if you were to port a complete ERP application, or anything big, from 2.6 to 3.x, it could be a bloodbath right now. The unicode changes for instance are the hardest to apply from 2.x -> 3.x, and the low level C APIs have changed a lot as well.

Because 3.x isn't backwards compatible with 2.x and a lot of apps and libraries are written for the 2.x series. 3.x was their attempt at cleaning up all the crud that never should have been in Python in the first place.... and they had to make some breaking changes. Probably best to stick with 2.x for now, til 3.x gains a bit more popularity.

The biggest differences are listed in the documentation of Python.
Hth. :)

If you're writing a new app, and don't rely on libraries that have no 3.x support yet, I suggest you go for 3.x. Let's create some critical mass :)
Take a look at the python 3 documentation itself

Because lots of libraries are not yet ported to 3.x I guess... And because lots of application still run on 2.x

Related

Starting with Python 2.x or 3.x? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'm not quite sure what the real differences are so I'm not able to decide which version is better for a beginner.
I have a background about C, C++ and Java basically, i would like to start Python because i need it, this will look like a noob question but i really don't know which version i'm supposed to pick; for what i see the difference between 2.x and 3.x are mostly related to the syntax used in the two versions, but since i don't even have started anything yet i know nothing so i ask: which one I'm supposed to pick ?
You can start with any of the version you want. Syntax are almost similar, the major differences can be found here:
http://docs.python.org/release/3.0.1/whatsnew/3.0.html
For learning though I would suggest 3.x because 2.x are frozen. There will hardly be any features added apart from bug-fixings.
For industry level application : 2.x because many libraries are yet to be ported ( example: mechanize, BeautifulSoup etc). Also Google App Engine does not support 3.x yet.
My suggestion would be to write code in 2.x, but make sure it can easily be ported. It's not that tough once you get the hang of py2to3 tool.
Just read this from python wiki. Short version: Python 2.x is the status quo, Python 3.x is the present and future of the language.
Personally I would install both, but for now use 2.x (2.7 or with some specific libraries 2.6) for developement, mainly due to better library support. And if the time comes, juping won't be too difficult, as the syntax changes aren't that substantial as Ashwini Chaudhary points. If you are just learning and don't need vast library support, go for the 3.x.
Most people are still using 2.x, even Django (one of the most popular web frameworks for Python) doesn't fully support Python 3 yet.
I would start with version 2.x. You'll have a lot less headaches when working with other libraries.

Which one to learn Python 3.x or Python 2.x? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I wanted to learn the python programming but I don't know which one to learn, I mean I think there are some difference between the two languages and I wanted to know which one is going to be used in the future. It does make sense if I learn Python 2.x and it is stopped being used by anyone.
Any info please?
Most useful modules still aren't ported to Python3. So if you need to call such things you are better off learning Python 2.x until they are ported. Even today the standard version of Python that OSes call is 2.x. (For instance OSX Lion has 2.7.1) Unless there's a compelling reason to use 3.x (such as just learning it so you're ready) then go with 2.x.
I had this same question and am always wondering why choose one over the other. Here's my approach. I learned python3 because it seems to have more 'stuff' in it than python2, but because most of the things can be done in either version, I usually code in python2.
The reason, like Clark mentioned, is most of the modules I need are in python2 but as they slowly move to python3 I'll be a position to quickly move over(google app engine only supports python2 right now but I read they a considering python3 support). So far so good, other than a few sytax differences its pretty simple to code between both of them.
One thing I learned from coding is although the language can be measured for its differences, it doesn't really have a huge impact on programming(at least for what I have done so far). Programming is more about how you think and at a basic level all languages will have tools to get the job done, so focus on what comes naturally to you and you enjoy.
Best of luck

django: on pypy, psyco, unladen swallow or cpython, which one is the fastest? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Has anyone tried to compare those python implementations?
pypy
psyco
unladen swallow (is it dead?)
cpython
I am planning to squeeze something more from my server.
Setup:
Django 1.3
Python 2.7
Psycopg2 1.4
apache 2
mod_wsgi
and... Windows server
I am not a windows fanboy, but it has to be :{ There is some legacy code working on it.
http://reinout.vanrees.org/weblog/2011/06/06/django-and-pypy.html links to some benchmarks that compare pypy and cpython using a small django framework (so I guess it just benchmarks how long it takes to create a view). You may be able to use the same benchmark with other frameworks, though it's far from being an all inclusive speed test.
I believe unladen swallow was discontinued.
One thing you should considerate is the C extensions. Different implementations require different extension ways. At present, the CTYPES may be the most common one.
So I recommend you take CPython, in case of possible C extensions.

New to Python... Python 3 and Matplotlib [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I want to learn Python. I have a course to do in Python 3. However, I will need to use mainly the matplotlib and Numpy, and these libraries are not yet compatible with Python 3. Is it worth doing the course in Python 3 or will be a waste of time to learn Python 3 and then came back to Python 2.x?
What would you do?
FYI, Matplotlib is now ported to Python 3.
You won't have a problem going back to Python 2.x after learning Python 3, or vice versa. There aren't too many differences. (Some standard library changes, print is a function, all strings are unicode -- you'll never notice most of them).
Realistically, if you learn Python 3 now, and get a job working with Python, you will almost definitely be working with Python 2.x for right now. Python 3 hasn't gained wide adoption yet. However, Python 3 will be more adopted in the near future, as a number of libraries are being ported to Python 3.
If you need to use Matplotlib specifically, then you should use Python 2.7 (no sense in using Python 3 right now if the library you need doesn't work for it). But learning Python 3 first will by no means put you at any disadvantage and may put you ahead of the curve when most people finally make the switch.
There's also nothing stopping you from using both (Python 3 for learning/experimenting, Python 2.7 for work).
"What would you do?"
I would port matplotlib to Python 3. :-)
But no, a course in Python 3 is not wasted. The differences are mainly in the standard library, and in subtle internal differences.
The major differences in the language itself is that the unicode type is called str in Python 3, and that print is a function. The differences are not so big that a course is wasted.
Another way to go is using something like cython which allows you to generate native python libraries that are compatible (without using 2to3 or 3to2) with both 2.x and 3.x. However, it is a bit of work. You do get to use set and dict comprehensions with versions of python that don't support those features though.

Why won't you switch to Python 3.x? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I ask this for deployable reasons. As in, if I write a solution in python, I feel bound to write to 2.x due to the lack of adoption of python 3. This is a major daily concern of mine, and I want to figure out what's going on.
For many of the python-based questions here, people are giving solutions that simply do not work in python 3.x.
So, I ask the question: What has prevented you from switching to python 3.x in your personal or work environment? The conversion script exists, and yet programmers (who are usually the earliest adopters of everything) seem to refuse to upgrade.
Why?
[Edit 03/10/2014: This answer is now out-of-date. Django has supported Python 3 for some time.]
[However, it must also be noted that the django third-party packages and extensions used in many Django projects are in various stages of Python 3 compatibility implementation. More details can be found in Django packages website which tracks the statuses of various projects.]
Django has not moved over to 3.0. That is all I need to know.
Related Questions
Will Python 3.0’s backwards-incompatibility affect adoption?
Is Python 3 a good starting point when you want to learn Python?
If I’m going to learn Python, should I learn 2.x or just jump into 3.0?
Who’s Using Python 3.0?
Python Version for a Newbie
Is it worth learning Python 2.6 with 3.0 coming?
Most of the answers in these questions echo the same sentiments. Aside from Django, too many frameworks/libraries - WxPython, PyGame, Django, etc - have still not adopted it. I'm sure as hell not making the move until they do.
Because major libraries that my codebase depends upon have not released a 3.x version. (wxPython, matplotlib, numpy, etc.)
So the responsibility goes upstream from my point of view.
If all my dependencies were 3.x compatible, I'd probably have switched by now.
Compiled 3rd party modules haven't updated.
Different syntax
Slower integers.
The #python IRC channel on freenode has in its title that its too early to switch.
3rd party tools and libraries. I'm having trouble making some things work under 2.6 (not a LOT of trouble, mind you, but some.)
As I see it, the ecosystem is one of Python's biggest strengths, and going to 3.0 at this point chucks a lot of that out the window. (In a year, I'm sure the story will be totally different.)
(Obviously, there's a chicken and egg problem here, but fortunately it's not my problem to solve, so I'll stay with 2.6 for a while.)
For many of the python-based questions here, people are giving solutions that simply do not work in python 3.x.
I think you answered your own question here. The lack of backwards compatibility makes 3.0 a much harder sell than a seamless upgrade because you have to adjust your thinking and discard some programming techniques to use the new version.
Call me back when they have an upgrade script for my brain.
Because the default installation of 2.5 on Mac OSX Leopard works just fine. I have no need to upgrade and I see no advantage to upgrading except an end to the woes of unicode.
If you are interested to move to Py3k one interesting way would be to write code in Py3k and use a 3to2 script which is being written now as a part of Google Summer of code project, on the lines of 2to3 script.
The operating system I use the most, Debian, does not have a Python 3 package, not even in the "unstable" (brand new) branch. Unless I compile it myself (which is quite 20th century), it means no Python3 to me.
I bet it is the same issue with many operating systems.
Unfortunately, for the same reason as most others have said - 3rd party libraries still not having been made 3.0 compatible.
For this reason, as well as that some GNU/Linux distributions (Ubuntu in my case) still comes with Python 2.6, I can't completely throw 2.x out the window yet.
However, the change to 3.0 is not a major one IMO. Except for "print" being a function and the new string formatting system, it's really more or less the same as before.
In fact, I find that most of my old scripts (those that do not depend on 3.0 incompatible 3rd party libraries) will work flawlessly in 3.0 after I update all the prints and string formatting. In some cases I've also had to change some module names (specifically stuff from the "email" module), but other than that nothing major.
Also, all the scripts I have updated for 3.x compatibility so far still seem to work flawlessly in 2.6 (but not older 2.x of course, as they lack the new 3.x syntax).
The main reason I am not switching is that so many books and coding challenge websites are still 2.x. I installed 3.x and realized very quickly that I had to uninstall and go to 2.x.
Because of the lack of backward compatibility, switching is hard, especially if there is C code involved. And although I understand the unicode/string thing may be very useful to some people, I certainly don't care about it myself.
Basically, Py3k did not solve many problem that I care about (distribution issues, versioning of modules, simplified import model).
Python 3+ does not support numpy.
Correction: it now does. As it now supports mathplotlib.

Categories