Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
Recently I decided to expand my programming horizons and learn the python programming language. While I have used python a little bit for classes in college and for a project or two at work I am by no means an expert. My question is as follows: should I bother with the 2.x releases or should I jump straight to 3.0? I am leaning towards 3.0 since I will be programming applications more for personal/learning use, but I wanted to see if there were any good arguments against it before I began.
Absolutely not 3.0 - 3.1 is out and is stabler, better, faster in every respect; it makes absolutely no sense to start with 3.0 at this time, if you want to take up the 3 series it should on all accounts be 3.1.
As for 2.6 vs 3.1, 3.1 is a better language (especially because some cruft was removed that had accumulated over the years but has to stay in 2.* for backwards compatibility) but all the rest of the ecosystem (from extensions to tools, from books to collective knowledge) is still very much in favor of 2.6 -- if you don't care about being able to use (e.g.) certain GUIs or scientific extensions, deploy on App Engine, script Windows with COM, have a spiffy third party IDE, and so on, 3.1 is advisable, but if you care about such things, still 2.* for now.
Use 3.1
Why?
1) Because as long as everyone is still using 2.6, the libraries will have less reasons to migrate to 3.1. As long as those libraries are not ported to 3.1, you are stuck with the choice of either not using the strengths of 3.1, or only doing the jobs half way by using the hackish solution of using a back-ported feature set. Be a forward thinker and help push Python forward.
2) If you learn and use 3.1 now, you wont have to relearn it later when the mass port is complete. I know some people say you wont have to learn much, but why learn the old crap at all? Python itself is moving towards 3.1, the libraries will move toward 3.1, and it sucks to have to play catch-up and relearn a language you are already using.
3) 3.1 is all around a better language, more stable and more consistent than 2.6... this is normal. The lessons learned from 2.6 were all poured into 3.1 to make it better. It is a process called PROGRESS. This is why nobody still uses Windows 3.1. It is the way things move FORWARD. Why else do you think they went to the trouble of back porting a feature set in the first place?
4) If you are learning Python, and learn 2.6, then by the time you are really comfortable with the language, the ports will be out, and you will have to learn the libraries, and the language all over again. If you start with 3.1, then by the time you are comfortable with the language, the ports will be out, and then you can learn the libraries that you are interested in. It is a smoother process.
5) To be a better developer. If you have to learn and relearn the same things, your understanding will not be very deep. By learning this language, and its libraries only once, you will have more time to work with them rather than relearning syntax. This allows you to understand them better. If you are really missing some pieces by forgoing on the libraries? WRITE THEM. You will probably not need an entire library, and can usually write only those pieces that you need, and develop tools for yourself. This, again, helps you understand the language better, and more deeply.
Short answer: Start with Python 2.6.
Why: Programming is more fun and useful when you can leverage the work of others. This means using 3rd party libraries often. Many of the popular libraries for Python don't have 3.x support yet. PIL and NumPy/SciPy come to mind. My favorite interpreter, ipython, also doesn't work with 3.0 yet. Many unit testing frameworks and web frameworks are also not on 3.0 yet.
So if you start out in 3.x many doors will be closed to you, at least until 3.x porting takes on steam. There are admittedly a lot of nice features in Python 3.x, but some of them have been backported to 2.6 and some more will make it into 2.7. So stick with 2.6 for now, and re-evaluate 3.x in a year's time or so.
I think that you will be better served going straight into 3.0. Unless you have a legacy codebase to contend with, there are very few advantages to learning the 2.xx ways of doing things.
In the Python world (as in most others, really), releases do tend to take a while to migrate down to all of the subprojects, but if you ever find the need to transition back to 2.xx, I don't think you'll find relearning things to be particularly painful.
You should go with the latest release of any programming language you learn unless you have a specific reason not to. Since you don't have an existing project that won't work with Python 3.0, you should feel free to use the newest version.
Use python 3.1, Luke.
Python 3.1 should not be used until other libraries have caught up with support for it.
You should use 2.6 now. It has several 3.x features back-ported to it, so that migrating to 3.x won't be difficult later on, and you won't learn obsolete practices.
The good news is that it's not really that tough to learn both Python 2.x and 3.x. You can install the latest 2.x version as the version registered with the system to run Python scripts by default, but also install the latest 3.x version to explicitly kick off when you want to. That's what I have on my Windows Vista system.
Then, the key document for learning the differences between the 2.x and 3.x versions is:
http://docs.python.org/3.1/whatsnew/3.0.html
If you read Python learning materials out there which are based on 2.x and also refer to that "What’s New In Python 3.0" link above, you'll get an understanding of how things changed. Also see the other whats new docs, like for the differences between 3.0 and 3.1, but the link above is the main one to understand the 2.x vs. 3.x changes.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I'm starting a new open-source software in Python, and I'm wondering whether I should use Python 2.x or Python 3.x.
It will include a heavy GUI, complex scientific algorithms dealing with large amounts of data. I'll need at least Numpy, Scipy, PyQT4, PyOpenGL, h5py, optionaly Matplotlib. It should first be released in 2013, with updates and extensions during the next few years.
It will be used by scientists that do not necessarily have a background in computer science, on a wide variety of computers (Linux, Windows, Mac...). Some machines may be old.
If I choose Python 3.x, I fear that the software and the third-party libraries may be more complicated to install, especially on old systems where Python 2.x is already installed. It would be better if RPM-like packages (or Windows installers) for Python and the external libraries were available on most systems, such that one doesn't need to compile everything. Also, I don't know if the 3.x branch is mature enough.
If I choose Python 2.x, I may need to port the software to Python 3.x in the near future if the 2.x branch becomes deprecated (when will that happen?).
What would be the best option?
UPDATE: My original answer was given in 2012. However, now, years later, the answer should and must be Python 3.
This wiki discusses exactly your question: Should I use Python 2 or Python 3 for my development activity?
This is a very large subjective part to this question which depends on exactly your specific situation and constraints.
IMO, however, if you can't be sure that all 3rd party libraries you need will work with Python v3.x I would stick with Python 2.x but try to write code to be as compatible with Python 3.x as much possible (e.g., print() etc) so that if you ever need or want to migrate to v3 your work won't be so challenging. And of course there are documentation and tools on moving from version 2 to 3. And this on porting v2 code to v3.
This will especially be the case on systems where you don't have control or can't install newer versions of Python or customize the installation of 3rd party software/libraries.
Given that your software will be run on a wide variety of systems (Linux, Windows, Mac ..) and by a number of different users I still think that v2 is more of a common denominator these days.
So, short-attention-span summary: Use version 2.x but perpare your code for v3.x
Finally, if you put this search string "[python] version 3 or 2" into the SO search box, you'll find a number of related posts:
Python 3. (The answer to this question has changed!)
Python 2 is for legacy projects. New projects should lean towards Python 3.
The reason for this is that Python 3 (now 3.6) is roughly getting a new release each year. It has also been stable for many years (is in its tenth release year!). In contrast, Python 2 (still 2.7) has changed little in the last several years and will continue to grow stagnant.
For more information:
https://wiki.python.org/moin/Python2orPython3/
I agree with Levon.
With those requirements, I wouldn't risk starting in Python3 yet, but you should write your code taking as many of Python3 changes into consideration as possible.
See this question Writing Python 2.7 code that is as close to Python 3.x syntax as possible as it might help you with some imports and standards that you can use to make your code as future-proof as possible.
Also, if you're running in a variety of systems, you'd need to either distribute your version of python bundled in the application, or trust the installation of the user. Most OS's (non-windows), come with a 2.x flavor of Python installed, and it's not trivial for a non-techie user to upgrade to 3.x without the possibility of breaking the system.
I just got Pycharm Community version and Python version2. something. I just wanna know if i can have a problem with the versions. Also What is the best way to use Python for?
PyCharm: Simplifying things a bit, PyCharm is just a fancy editor. Unless you have it deeply ingrained into your workflow, you can always switch to a different editor, should PyCharm cease to fulfill your needs.
Python 2 is not the newest version of the language; that would be Python 3.6 as of now (that is, the summer of 2017). So, theoretically, if you start to write lots and lots of code and then later decide, when Python 2 is no longer maintained and third-party libraries drop their support, that all your code should now be compatible with Python 3, you may find yourself in the uncomfortable situation that you suddenly have to port all your code to Python 3, but you lack the ressources to do so. If you recently started programming in Python and have no prior investment, you might consider using Python 3 instead.
Otherwise, simply write modern Python. If you do a serious project, write unittests. Then porting to Python 3 is doable.
What is the best way to use Python for? Python is a multi-purpose language used in all kinds of contexts. It is often used in the scientific community. But it's also used a lot for web services, in education, as an embedded scripting language and many of other use cases. What are your interests? Just use Python for that.
Based on my project, which is the best version of Python to use? Which is the best IDE to use that runs on Linux (Ubuntu) and Windows? Here is the background for these questions:
I'm building a small application GUI that features "drill-down" views and direct manipulation on personalized calendars. Should I use Python 3, the newest version, or an older version is better at this GUI task? I've heard that some of the old GUI libraries do not support the new version yet, but not quite sure if this will matter a lot. Could you please name the libraries that might be relevant? Even better if you could suggest your preferred IDE either under Windows or Ubuntu. Many thanks.
You can use vim as IDE.Start program with 2.7 version with 3.0 in mind.Have a look at this python 2 or 3
Depends a bit on which GUI you use. If you're using PyQt, it supports v3. wxPython, however, does not.
As a rule of thumb, for now, you can pretty much use python 3.0 syntax in 2.7, and keep things compatible going forward. I'd say, except for print statements, the differences aren't that mind-blowingly different between 2-3. IDE's pretty much support both - and gnud's links are pretty good for that.
Popularity
When selecting a framework to learn, popularity is a reasonable gauge of how good a framework is, and how easy it will be to get support when you run into problems. The tags on stackoverflow are a quick way to get a ballpark idea.
Environment
Start with what you're the most familiar with. When learning something new, there is so much to absorb, that having something familiar really helps.
For example, when I taught myself python a year ago, I used pydev in eclipse, because I've been a cross-platform java developer using eclipse for quite some time. Made life much easier.
If you're starting from ground zero, it doesn't matter very much. Pick something popular that you feel comfortable in and start coding. As you become familiar with what you're doing, you'll be able to compare other packages and determine if it's right to switch.
The popular IDE's are cross-platform. Graphics packages too, although usually one is stronger on unix or windows.
SublimeText2 has excellent Python support.
Also you can use PyDev for Eclipse.
About versions: I think you should write 2.7-compatible code, but be ready( and know how) to update it to 3.2 or later.
I'd recommend starting with 2.7 since most libraries work with it. The differences between both are not too big, so you might even be able to switch if you want to in the future. But before you choose Python 3 and you find a library you really want to use and it's not available for Python 3 you would regret choosing.
wxPython and PyQt are pretty popular. wxPython doesnt support 3 yet...
I prefer PyCharm it's not free but it's so great and it has so many features...
One of the best code-completion i ever had for Python.
P.S.: if its really simple you mgiht even consider using tkinter.
Is 2.x still the norm or would you recommend just coding in v3 at this point?
Python 3 is still a long way off having universal support from tools, libraries and distros, so its use in production would depend very much on whether the bits you need (or are likely to need in the near future) have been ported.
For exploratory, educational and other uses, it depends very much on your own proclivity for living on the bleeding edge. If you are happy building from source and debugging and hacking third-party libraries to get things working, then you'll probably have no issues with Python 3. Otherwise, stick to the latest your distro offers, and if it is stuck on a really old Python — CentOS is still on 2.4! — you have my commiserations. Personally, I steer clear of CentOS for precisely this reason.
Google App Engine documentation states it uses Python 2.5
Today I happened to notice that Python Imaging Library is till not released for 3.x.
So, if you need those libraries or services, I guess you should wait.
Do the frameworks and libraries you use have Python 3 versions? Libraries you use for development, and does your deploy stack support Python 3?
Many Python projects have a lot of dependancies, especially web based projects, most of which aren't Py3K ready yet.
If your stack is good, sure - Python 3 is the future, might as well embrace it now.
My main use of Python is Django. Support for 3.x for this framework still lies in the future, unfortunately, and who knows about any related modules - so no, it's not quite time for many people.
I actually bought Python 3 books last year when I started learning Python, thinking "I'll just start with 3 from the beginning!". That didn't work out, though.
I've always used v3 primarily. "Hacking 3rd party libraries" to me is just like importing any other module. The only thing is since most stuff still uses v2 you have to know both versions and keep them straight when looking at others code.
G'day,
I'm wanting to go back to Python after not using it for a while and I saw this question "Python Version for a Newbie" while wondering about getting back into Python 2.6 or Python 3.
Almost all of the questions' answers were along the lines that most of the code out there, libraries, legacy systems, etc., is 2.5 or 2.6 rather than 3 so start with 2.x now and then head towards 3 later on.
Given that the question and all answers date from early December 2008 I was wondering is this still the case?
Should someone who wants to get back into Python maybe start off with 2.6 and then head towards 3 later on?
Yes. Virtually all live production systems will use 2.5/2.6 for a long time yet. There's no point learning 3.0, only to have to downgrade it because your host doesn't support it.
95% of what you will learn in 2.5/2.6 is applicable to 3 anyway.
Depends on the amount of libraries you're going to use.
Raw Python, or all libs are available for Py3k - go for it without any doubts.
Python code distributed as standalone app (using PyInstaller), relying on some GUI lib, XML-lib, win32api etc - double check if all libs are available at least as betas for Py3k. Chances are still quite high that some older lib is not available for Python 3.x, and either you port it by yourself to new Python version, or you switch to some other lib or - stick to Python 2.6 for a while.
If you want to use only standard library then try Python 3.1. If you want to use others libraries/frameworks then they dictate the version to use. For example web2py framework will work best on 2.5.
I would say that Python 2.4 is the safest to learn, but the changes from 2.4->2.5->2.6 make some small progress towards Python 3.x, even if they may never make it (if I recall there will be some more steps?).
Python 3.1 can be used if you own a dedicated server and intend to build your own applications from the ground up. WSGI does support this, but I wouldn't recommend it.
As has already been said, I would learn the Python 2.5 or Python 2.6 style, but I would make a few changes.
Look at the Python 3 style regarding brackets.
e.g. The print function in 2.x has always been just
print "Hello World"
Where as in 3.x you need to enclose it
print("Hello World")
This is probably a good practice to pick up on, but things like Exceptions will cause issues if you use 3.x in 2.x. I know it's probably a bit confusing, but if you make sure you wrap your functions (additional brackets shouldn't really hurt most things) so that nothing is bare (bare like the first code snippet above), then it'll help with the transition.
The problem is, if you started with 2.4 or more it is better if you start from there, so you'll get on track faster, after some time when you feel comfortable with you code you can try 3.0 and find out what did they change and learn the new style.
I for once still code in 2.6 style and follow those guidelines, still haven't seen the changes in 3.0