Hey, in this video, we will talk about Python versions.
You will understand what a Python version is and why it is important to know about Python versions.
So let's begin let's talk about some history first, Python version 1.0.0 or simply Python one was released
in 1994 and six years after that, Python two was released.
In 2000.
Eight years later, point three was released and currently Python three is the current version now.
These were major releases, 1 to 3, but there are also minor releases and patch releases as well,
which I'll talk about now.
So when you download a python interpreter from Python dot org, you download something like Python 3.8
11.2 or python three point 12.7 or python three point 10.8 etc..
Now the last number.
Is the patch release.
So this is a release of a new Python version.
For example, when we switch from three point 11.1 to 3.11 point two.
So the Python developer team releases Python three point 11.2.
And in that release, what happens is that there are bug fixes and other small changes in that particular
release.
Now this release is backwards compatible, which I'll talk about in just a bit.
Then we have the minor releases.
Now these are bigger features.
So it's about, for example, switching from Python 3.10 to Python 3.11.
So the second number indicates bigger features in the newer version that is released.
And this is also backward compatible.
Now, when we have a major release, for example, when we when we go from Python two to Python three.
There are many big features that were released and the code is not backwards compatible.
Now, what does backwards compatible mean?
This is what I'll explain right now.
So let's look at an example for that.
Here.
And this winter here I've started a Python 2.7 interactive shell, so I'm using the interpreter of Python
2.7, which was released many years ago.
And down here I've started a Python 3.10.
Interactive shell.
So I'm using the Python 3.10 interpreter down here now in Python 2.7 to print a string we could use
print.
Hello.
Just like you see, it's here without the parentheses and you get the hello string.
Ah, but in Python 3.10 if you do print hello like that, you'll get an error.
So that means python 3.10.
Or to be more exact, Python three is not backwards compatible because what's exactly a release?
A release, For example, when Python three was released, what happens is that two things.
First is that an interpreter program is created and you can download that, but also the documentation
of the language changes to fit this new interpreter.
So the new interpreter expects this kind of code print with parentheses.
So like that.
So the new interpreter for Python three expects that.
Code and in the documentation you'll also see this code documented.
And so this new version of Python Python three ignores the code that was available in Python two.
Now, practically for programmers, what does it mean practically?
Well, let's suppose that you have written a web application and the code is something like this.
Let's suppose this is a code.
So you have written it in Python two.
And this code is now running on a server computer.
And this code produces your website, your web application.
But now Python three is released.
So you have two choices.
Either you ignore Python three and you keep running this code using your Python 2.7 interpreter or 2.6
or whatever.
So python two and your app will keep running just fine.
Right?
So you can ignore python three.
Or the other option is that you go to your code and you make the necessary changes.
So you add parentheses here in this Hello string and here row inputs you change it to input because
in Python three row input is not used anymore, so input is used instead.
And so once you make this changes, then in the server you instruct your server to run your code using
part from three The Python three interpreter.
In that case, you can say that you have upgraded from Python two to Python three.
So after doing these two things, changing the code to fit Python three syntax and also changing the
Python interpreter to to run this code using the Python three interpreter.
Now, this could be a hustle.
So many programmers could just leave the code base to run on Python two and they don't change the code.
But after many years, Python two will not be supported anymore.
So there might be security issues with Python two.
And in that case, as a developer, you have to go to your code base and change the code base to Python
three.
So that you benefit from this minor releases of Python like the minor release here and the patch, which
will happen in the current major version of Python.
But in the previous major version such as Python four one or two, these changes will stop.
After some time.
So the developers of the Python team will not be working any more on Python two.
So that's what you should know about Python versions.
Now, as a learner, it doesn't really matter if you're using Python 3.10 or Python 3.12.
The changes are very, very small.
And so the code you wrote using Python 3.10 in mind will work even if you run it with Python 3.12 for
later on because you are still in the same major version.
Only if Python four is released later on, then you might want to think about upgrading your code to
Python four.
As I explained when I did the comparison between Python two and three.
Yeah, that's.
Thanks and see you later.