Python security best practices
In this section, we'll look at Python security best practices. We'll do this by learning about recommendations for installing modules and packages in a Python project and review services for checking security in Python projects.
Using packages with the __init__.py interface
The use of packages through the __init__.py
interface provides a better segregation and separation of privileges and functionality, providing better architecture overall. Designing applications with packages in mind is a good strategy, especially for more complex projects. The __init__.py
package interface allows better control over imports and exposing interfaces such as variables, functions, and classes.
For example, we can use this file to initialize a module of our application and, in this way, have the modules that we are going to use later controlled in this file.
Updating your Python version
Python 3 was released in December 2008, but some developers...