I'm going to learn Python. The scope is the most extensive: Web, Machine Learning, big data processing, graphics ...

Which version to choose? Does Django work fine with Python version 3?
For version 2 more description and tutorials.

  • 3
    As for me, start with 2.x and learn actively, 3.x - look, compare, understand the differences. I think in 3-5 years the branch 2.x will catch up with the modern 3.x. And 3.x meanwhile turn into 4.x or even 5.x. I refer to version 3 as a kind of stable beta language, and 2 - as stable for industrial code. But no one bothers to write code so that it works in both versions of python. - KoVadim
  • Is there a fundamental difference in performance? - xmaster83
  • one
    @ xmaster83, 1. There is no fundamental difference. 2. This is generally the last thing to think about - the performance of the final application will depend much more on the chosen algorithms and architecture than on the language. - etki
  • one
    I solve different algorithmic problems with number shredders. 2.7 usually 1.5 - 2 times faster 3.3. (with almost the same code). By the way, the biggest plug is the range-xrange in cycles. In the second range python, a complete list is generated and then iterated. If the range is large, the memory eats a lot. xrange is a lazy operation, it will not give up the next element until it is needed, and it does not need it on the dimensions of the range. So in the 3 python range behaves like the xrange of the second, but the xrange in the third is not. - KoVadim
  • @KoVadim, where is the plug? Anyone who is programming more or less on python knows that xrange should be used almost everywhere. Now, if in the 3rd python there was a xrange, and it would behave like a range in the 2nd, it would be a plug =) - dzhioev

1 answer 1

You can learn both. In fact, it is one language. And for specific projects to choose what is more suitable - 2.7 or 3.

The fundamental difference between the versions is the severity of the approach to mixing Unicode and byte strings. Standard types more commonly use default iterators. In version 3, some rough spots were also removed, such as implicit relative imports, syntax for exceptions corrected, list comprehension names, etc. A new syntax has been added, for example, yield from , which allows you to conveniently program with such things as asyncio. Some standard modules have been reorganized, for example, the urllib2.urlopen() function is the urllib.request.urlopen() in Python 3. Google will always tell you where everything lies. Surface things, such as the print function in the 3rd version and the print instruction in the 2nd, are recognized as they are used.

Many projects use the same source code for Python 2 and 3. So you don't even need to learn different APIs. Many popular libraries can work on Python 3 .