Important new features in Python 3.8

Bravelab
Bravelab Developers

Read time: 5 min

Dec 13, 2019

Assignment operator

The assignment operator lets you create value assignments within larger logic expressions.

Example

  
    >>> if ( value := 1 + 1 ) > 1: # 2 > 1
	   print(value)
2
>>>
  

In this example, we assign 1+1 to a variable (value) and check if it is greater than 1. It is important to note that you can also use an assignment operator inside list comprehension.

New f-strings specifier

Python 3.8 introduces a new ‘=’ specifier available to use inside f-string expressions. The specifier will automatically get the object name with the object value paired.

Example

  
    >>> object='example_value'
>>> f'{object}'
'example_value'
>>> f'object={object}'
'object=example_value'
>>> f'{object=}'
"object='example_value'"
>>> f'{object=!s}'
'object=example_value'
>>>
  

This new feature will certainly be helpful in testing and logging. As you can see in the example, it is also possible to use this conversion flag with the new specifier.

New importlib.metadata module

New importlib.metadata module can help you read metadata, such as the version number for packages installed with tools like pip. Let’s check the installed version of Django and its requirements.

Example

  
    >>> from importlib import metadata
>>> metadata.version('django')
'3.0'
>>> 
>>> metadata.requires('django')
['pytz', 'sqlparse (>=0.2.2)', 'asgiref (~=3.2)', "argon2-cffi (>=16.1.0) ; extra == 'argon2'", "bcrypt ; extra == 'bcrypt'"]
>>>
  

Removed features in Python 3.8

- The macpath module - isAlive() method of threading.Thread - platform.popen() method

Deprecated features in Python 3.8

- getchildren() and getiterator() methods of ElementTree - lgettext(), ldgettext(), lngettext() and ldngettext() of gettext module

To sum up, if your career path includes Python development, it is worth keeping up to date with python releases systematically. Check out our blog for more news.

Bravelab
Bravelab Developer who is detail-oriented, enthusiastic about data analysis and highly focused on implementing modern solutions to help out business to grow.

Read time: 5 min

Dec 13, 2019

Our mission is to be /trusted partner
to our clients/
in the field of webplatform
development & staff augmentation

Check our rank

developmentclutchdevelopment
  • development
  • clutch
Item 1 of 3

0 Professionals

0 Finished project

Kudos.

  • “Not afraid of doing even the most difficult tasks and proposing innovative solutions. They don’t avoid challenges, rely on new technologies, and - most importantly - always carry the projects through from the beginning to the end.”

    Adam Bogdan
    Adam Bogdan Python Developer
Item 1 of 9

Contact.

We're happy to help! Leave your contact data, and we will get in touch with you within one business day.

Tell us about your needs, ask about our experience, portfolio, and even partnership programs.

Contact us

This website stores cookies on your computer. These cookies are used to collect information about how you interact with our website and allow us to remember you. We use this information in order to improve and customize your browsing experience & for analytics & metrics about our visitors both on this website & other media.
To find out more about the cookies we use, see our Privacy Policy.