I am interested in learning Python but I don't know which version I should chose. When I Googled, I got answers posted over a year ago. If I want to learn Django, which version will be useful and will get support?
Note that I know C, C++, Java and C#.
Django only has experimental support for Python 3, so you'll have to go with Python 2.7 for now.
First, a short comparison is It's Better than 2.7 and When should Python 3.3 become the default. However, remember that Python is in fact a script language and you can use C or C++ in doing modules with new capabilities.
I would recommend to start with python 2.7, it just more commonly used nowadays, and django is written in 2.7 AFAIK.
Apparently the answer you found still holds:
Should we use python 2.6 or 2.7 or 3.x?
If you already know several languages then learn both Python 2 and 3. The difference is small enough to allow many projects to support both versions using single (the same) source code.
For actual deployment you might prefer Python 2.7 if you need to use dependencies that are not ported to Python 3.
Related
Yes, I know about IronPython 3 compatibility, but that is from two years ago. I was searching on the internet but couldn't find any information on this that is up-to-date.
So does IronPython support Python 3? If not, how many of the future imports work, and are there any Iron-specific ways to make it seem more like Python 3?
Currently it doesn't support Python3. IronPython3 Todo. All future imports supported by the standard Python 2.7 interpreter should be supported by the newest version of IronPython.
And there are no Iron-specific ways to make it seem more like Python3 as far as I know.
IronPython 3 is once again alive. An alpha for Python 3.4 was released in April 2021. It is a very active effort which is being supported by the .NET Foundation. More here: Python 3.4 Release Notes
You can use ExaScript, a fork of the IN-DEVELOPMENT IronPython 3, providing standard Python libraries along with multiple specialty libraries, such as PowerCrypt4, a cryptography library, OmniBeanLib, a library containing lots of common functions, and OmniBeanEB, a rewrite of the Small Basic Library that provides almost every function necessary to build a good GUI/Console application.
Best of all, for making Windows Forms applications, use EPFramework, an included library to generate a fresh, reactive, modern UI for your project.
I have been learning python for some time now. While starting this "learning python" endeavor I decided to learn the latest and greatest 3.1 version of python. I regret this decision now because I wanted to try my hands on some of the python web development frameworks & it looks like many of them do not support 3.1 yet & it looks like it might take them years to support the new version of Python especially Django and TurboGears. This is really disappointing. Therefore, SO users, do you have any recommendation for a web framework for me that runs on 3.1 and supports some of the modern (I guess I will never learn ;-)) web framework features like MVC/ORM/URL Routing/Caching etc.
How about trying Python2.7?, many of python 3.x features are backported to 2.7 recently, like OrderedDict, faster io modules, set comprehensions, dict comprehensions, etc...
And Python 2.7 is running no problem at all with django 1.2 trunk version in my experience.
In my opinion, learning new framework will take more time than switching from Python2.x to Python3.x, So choose one framework, and just keep using python 2.x and switch it to 3.x when the time come.
Like the others, I would suggest you start with Python 2.6.x -- Python 2.7 will be released this summer although you can grab an alpha or beta version today.
Although Python 3.x is backwards-incompatible with 2.x, Python syntax isn't going to be unrecognizable... pretty much everything is very similar to 2.x, but it's easy to break code when print changes from a statement to a function. So don't worry about Python 3 for now. As others have mentioned, you can get started right away with plenty of web frameworks that work in Python 2.x.
Also, just because of the numbering, do NOT be fooled in thinking that Python 2 is obsolete in any way nor can you follow the timeline serially. In other words, Python 2.7 will be newer than both Python 3.0 and 3.1. (3.2 won't be released until the end of this year.) Again, Python 2 has NOT been EOL'd -- both 2.x and 3.x are being developed actively.
The industrial world still runs on Python 2.x; the appearance of 3.x is a reminder that the next generation is here, and this is the time that all of the lower-level infrastructure and frameworks should begin their porting work so that we'll all eventually migrate.
If you want to find out more about the relationships between Python 2, Python 3, and the changes/differences between the two as well as the timeline and migration, you can check out this online article I wrote earlier this year:
"Python 3: The Evolution of a Programming Language"
http://www.informit.com/articles/article.aspx?p=1328795
I also gave a talk on this same subject at PyCon 2010 in February. You can access the video and the slide preso here:
http://us.pycon.org/2010/conference/schedule/event/29/
CherryPy 3.2 (still being worked on) will run on Python 3.x
Bottle can also run on Python 3.x after using 2to3 on it. Easy to do and it does work. However, Bottle is not a 'complete framework' but it is easy to use.
Edit:
I have used Bottle in Python 3.1, stackless python 3.1 to be specific, for a game that I am slowly working on. But at work, I am just using Python 2.6 And soon I will be using Webpy.
The site I work on is in PHP, but when I need to add a new feature, that I can easily separate from all the PHP code, I will do it in python. Even though I work with PHP almost everyday and use Python only a few times a month, I still can get things done faster in Python than PHP :)
Python 2.6 and Python 3.1 are really not all that different, I simply suggest you learn both, especially since both branches of Python are going to coexist for a while... so best to just learn the slight differences. The document "What's New in Python 3.0" explains most of the differences between 2.6 and 3.0.
There is ( are) actually a Django port to Py3k.
http://bitbucket.org/loewis/django-3k/
I can also remember quite good of having read a thread about a University project of porting Django to py3k, on the django-developers mailing-list, but I can't find the thread at the moment.
EDIT
Oh here it is:
https://bitbucket.org/fiji/django-3k/
The project is lead by students at the University of Toronto. :-)
ENDEDIT
Querying for something like "Django py3k port" brings up some useful results.
Also look at these URLs:
http://wiki.python.org/moin/PortingDjangoTo3k
http://groups.google.com/group/django-developers/browse_thread/thread/bf9d8808ee5aadb4/ccceb8901addceff?lnk=gst&q=django++port+py3k#ccceb8901addceff
This question already has answers here:
Closed 12 years ago.
Possible Duplicates:
Is it advisable to go with Python 3.1 for a beginner?
What version of Python should I use if I’m a new to Python?
Haven't really made anything in Python... Which Python should I take ahold of? 2.X or 3.X?
2.X still offers a far wider variety of third-party libraries / frameworks, instructional websites and books, and experts to help you out -- I expect this will continue for a few years until 3.X gradually overtakes it. Right now, therefore, I would still recommend 2.X despite 3.x's even-greater "clean-ness" and simplicity (because some cruft which 2.x has to keen around for backwards compatibility was finally wiped out in 3.x). Very few new features of 3.x are not backported in 2.x, by the way -- e..g, if you want print to be a function, like in 3.x, in your 2.6 or 2.7 module, just put, at the start of the module, the statement
from __future__ import print_function
"Importing from the future" is a typical Python way to make new features available when explicitly requested, without breaking backwards compatibility.
You are in luck! Due to a lot of confusion about this people have put together a wiki page in the last few days: Should I use Python 2 or 3?
I'd say it depends where you are going to run the code. If you have complete control over the environment, use 3.x. If your environment is controlled externally (cheap webhosting for example) then you will probably need to use 2.x. The only other reason to stick with 2.x is if a critical library you can't live without hasn't been ported to 3.x yet. Don't saddle new code with 2.x-isms if you can avoid it.
2.x
Quite some modules have not yet been ported to python 3 and you will find much more books, online resources for learning python 2.x
You also can't rely on python 3 being preinstalled, while for most linux distributions you can rely on some version of python 2 being available. The only one I know of that already has python 3 packages is the latest Fedora 13. If that matters to you depends on your needs.
See also this related (though not identical) thread on Python 3.0.
While I think the case for 3.x is more compelling than it was a year ago, it still doesn't have the breadth of third-party library coverage of 2.x. I would suggest developing for 2.6 and making use of the migration utilities when the time finally comes (e.g. some dependency is forcing you) to move to 3.x.
If you are just learning Python (and you don't have a specific project you need to complete), I'd suggest that you start with the newest version (3.x). Even if you start with 2.x, though, the basics will be the same, so you will be able to learn any differences in 3.x very quickly.
Go with 2.x
I ran into a lot of compatibility issues with libraries and Python 3.x, although I can't recall which ones specifically. The specific issue I was seeing had to do with unicode strings, which I understand is the default in Python 3. The library threw an exception when using unicode strings, and returned an error for normal ASCII strings. This was about 6 months ago, and I'm assuming the support hasn't drastically improved since then.
If you're absolutely sure you won't use any external libraries, 3.x might not bite you. As a compromise, you could use 2.x and try to avoid the changes in 3.x to make it compatible.
I am just learning python on my ubuntu 8.04 machine which comes with
python 2.5 install. Is 2.5 too dated to continue learning? How much
of 2.5 version is still valid python code in the newer version?
Basically, python code, for the moment, will be divided into python 2.X code and python 3 code. Python 3 breaks many changes in the interest of cleaning up the language. The majority of code and libraries are written for 2.X in mind. It is probably best to learn one, and know what is different with the other. On an ubuntu machine, the python3 package will install Python 3, which can be run with the command python3, at least on my 8.10 install.
To answer your question, learning with 2.5 is fine, just keep in mind that 3 is a significant change, and learn the changes - ask yourself as you code, "how would this be different in 3, if at all?".
(As an aside, I do wish Ubuntu would upgrade to 2.6 though. It has a nice compatibility mode which tries and points out potential difficulties. But python is in such big use on a modern Linux distro, it can be a difficult change to make)
Here's an article describing 2.6 -> 3's changes
Python 2.5 will be fine for learning purposes. In the interest of learning you will probably want to look into the differences that python 3.0 has introduced, but I think most of the Python community is still using Python 2, as the majority of libraries haven't been ported over yet.
If your interested in 2.6 here is a blog post on compiling it on Hardy, there may even be a package for it somewhere out there on the internets.
Follow up, if there is a package I'm not finding it. Self compiling is pretty simple for most things, though I've never tried to compile Python.
I don't think it is 'too dated' to use, but there are some really nice features in python 2.6 that make it worth the update. This article will give you the details. As long as you have control of the machine, it is worth it.
I don't have any statistics but my impression is that Python 2.5 is the version most in use today. It is certainly not "dated" - I still use Python 2.5 and I expect that I will be using it for weeks or months yet to come.
If you have Python 2.6 available, though, I would suggest upgrading, as it's still fairly similar to Python 2.5 but will put you in better position for using Python 3.
Also, right now the 2.x branch is the most supported one, so I would also say that it's a good reason to start with that version.
And when the moment comes, you can always switch to Python 3.
Python 2.5 is fine. There are still plenty of people on Python 2.4 and 2.3.
One thing to keep in mind about python 2.6 is that some libraries may not work. Numpy comes to mind..
If I learn python 3.0 and code in it, will my code be still compatible with Python 2.6 (or 2.5 too!)?
Remarkably similar to:
If I'm Going to Learn Python, Should I Learn 2.x or Just Jump Into 3.0?
No, 3.x is largely incompatible with 2.x (that was actually a major motivation for doing it). In fact, you probably shouldn't be using 3.0 at all-- it's rather unusable at the moment, and is still mostly intended for library developers to port to it so that it can be usable.
Python 2.6 and Python 3.0 are very compatible with each other. There honestly aren't very many differences between the two. At this point, third-party library support is far better for the 2.x series (last I checked, a few libraries I use hadn't been updated from 2.5, but going from 2.5 to 2.6 is just a recompile, but 2.6 to 3.0 for C-level stuff is a real pain).
Just start learning 2.6. The infrastructure is there now, and there's plenty of help for when you finally want to move to 3.x. 2.x is not going away: there will be a 2.7 release at some point, so you're not going to be out of luck if you learn 2.6 now.
It would be easier to use 2.6 right now because most external libraries are not compatible with 3 yet.
NO. Python 3 code is backwards incompatible with 2.6. I recommend to begin with 2.6, because your code will be more useful.
In most cases it's not required anymore learn to Python 2 along with Python 3 for the following reasons.
Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained, and dedicating effort to learning it doesn't make sense anymore for most people. Also there may be problems installing some Python 2.7 packages that don't have any problems installing them in Python 3.
Python 3 is the best way to learn Python for the first time, because it's easier for beginners to understand than Python 2.