Python

Asynchronous code has increasingly become a mainstay of Python development. With asyncio becoming part of the standard library and many third party packages providing features compatible with it, this paradigm is not going away anytime soon.

Let's walk through how to use the aiohttp library to take advantage of this for making asynchronous HTTP requests, which is one of the most common use cases for non-blocking code.

What is non-blocking code?

You may hear terms like "asynchronous", "non-blocking" or "concurrent" and be a little confused as to what they all mean. According to this much more detailed tutorial , two of the primary properties are:

Logging is one of the most important aspects of software development. The developers log events like successful completion, warnings, errors, fatal errors, etc. These logs can help developers in various ways like find out the root cause in case of when some failure happens in the future, look for slow parts of the code for optimization, etc. Python provides a module named logging which has a vast API that can be used to log events in Python. We have already covered a very detailed tutorial covering the majority of the API of python logging module . Please feel free to check it if you are interested in learning about it (link below). This tutorial will build on that tutorial and explain how we can configure logging module based on the configuration from dictionary and configuration files. It's recommended to have knowledge of the logging module explained in that tutorial to continue with this tutorial.

Generally speaking, type checking and value checking are handled by Python in a flexible and implicit way. Python has introduced typing module since Python3 which provides runtime support for type hints. But for value checking, there is no unified way to validate values due to its many possibilities.

One of the scenarios where we need value checking is when we initialize a class instance. We want to ensure valid input attributes in the first stage, for example, an email address should have the correct format xxx@xxxxx.com, an age should not be negative, the surname should not exceed 20 characters, etc.

1/6 »