Code is always changing and evolving - and its important that you can keep up with it!
While you'll still be able to write with your older knowledge (its not as if they're about to break all of the old apps we use just because they've found a better way to do things), using the new features and tactics that are introduced in new versions will help increase your efficiency.
Youll also be able to do more things with your code, which is always exciting!
That being said, its important that you stay on top of all the new features that Python rolls out. This is a great way to give yourself an edge over other Python programmers and really make your code shine.
So without further ado, lets dive into the new updates in Python 3.8!
Of all the features added to Pythons 3.8 version, this is really something to be excited about! Python has created a walrus operator := that allows you to assign values to a variable as part of an expression. There are a lot of cool things about this, but the best aspect is definitely the lines of code youll save while you make your apps.
Now, instead of writing this:
line = f.readline() while line: line = f.readline()
You can write this:
while line := f.readline ():
See? Much better!
Anyone who has worked with Python in the past knows that Python 3.2 brought about an interesting problem that altered unpacking iterables without parentheses in return and yield statements. There was, of course, a solution. But it took up extra lines of code - and we all know what a pain that can be.
Before we explore what the fix looks like (finally!), lets take a look at the before and after for this feature.
Before, you could only write something among the lines of the following code:
def foo(): rest = (4, 5, 6) t = 1, 2, 3, * rest return t
If you tried to plug in the following code, however, youd return an error code.
def baz(): rest = (4, 5, 6) return = 1, 2, 3, *rest
And you certainly couldnt write the following code.
def baz(): rest = (4, 5, 6) yield = 1, 2, 3, *rest
In the new version, however, both of these will be accepted without returning any traceback errors! Yes! Its about time! Youll be able to save time writing code and focus on more important coding issues.
There are tons of fantastic new features that have been rolled out with the introduction of Python 3.8. You can spend countless hours exploring all of the new features and the impact it will have on new code you generate.
To make sure you fully understand how to integrate Python 3.8 into your work, check out more new features by visiting python.org. You can also look at how Google, Firefox, and other platforms are using the new changes in their software - you may just find more awesome easter eggs!