Testing applications has become a standard skill set required for any competent developer today. The Python community embraces testing, and even the Python standard library has good inbuilt tools to support testing. In the larger Python ecosystem, there are a lot of testing tools. Pytest stands out among them due to its ease of use and its ability to handle increasingly complex testing needs.
ᗧ•••ᗣᗣᗣᗣ•• #Python #SRE #DevOps #DevSecOps #ETH #CHFI #CEH #CISSP #RedTeam #BlueTeam
Mostrando entradas con la etiqueta Python. Mostrar todas las entradas
Mostrando entradas con la etiqueta Python. Mostrar todas las entradas
Python Modules and Packages
There are actually three different ways to define a module in Python:
- A module can be written in Python itself.
- A module can be written in C and loaded dynamically at run-time, like the
re(regular expression) module. - A built-in module is intrinsically contained in the interpreter.
A module’s contents are accessed the same way in all three cases: with the
importstatement.Absolute vs Relative Imports in Python
A Python module is a file that has a
.py extension, and a Python package is any folder that has modules inside it (or, in Python 2, a folder that contains an __init__.pyfile).
What happens when you have code in one module that needs to access code in another module or package? You import it!
Memory Management in Python
Memory Is an Empty Book
You can begin by thinking of a computer’s memory as an empty book intended for short stories. There’s nothing written on the pages yet. Eventually, different authors will come along. Each author wants some space to write their story in.
Since they aren’t allowed to write over each other, they must be careful about which pages they write in. Before they begin writing, they consult the manager of the book. The manager then decides where in the book they’re allowed to write.
Since this book is around for a long time, many of the stories in it are no longer relevant. When no one reads or references the stories, they are removed to make room for new stories.
Docker in Action
With Docker you can easily deploy a web application along with it’s dependencies, environment variables, and configuration settings - everything you need to recreate your environment quickly and efficiently.
We’ll start by creating a Docker container for running a Python Flask application. From there, we’ll look at a nice development workflow to manage the local development of an app as well as continuous integration and delivery, step by step …
Offline Python Deployments With Docker
In cases when a production server does not have access to the Internet or to the internal network, you will need to bundle up the Python dependencies (as wheel files) and interpreter along with the source code.
Objectives
By the end of this post, you will be able to…
- Describe the difference between a Python wheel and egg
- Explain why you may want to build Python wheel files within a Docker container
- Spin up a custom environment for building Python wheels using Docker
- Bundle and deploy a Python project to an environment without access to the Internet
- Explain how this deployment setup can be considered immutable
Continuous Integration With Python: An Introduction
What Is Continuous Integration?
Continuous integration (CI) is the practice of frequently building and testing each change done to your code automatically and as early as possible. Prolific developer and author Martin Fowler defines CI as follows:
“Continuous Integration is a software development practice where members of a team integrate their work frequently, usually each person integrates at least daily - leading to multiple integrations per day. Each integration is verified by an automated build (including test) to detect integration errors as quickly as possible.” (Source)
Profiling Python in Production - How We Reduced CPU Usage by 80% through Python Profiling with Nylas
We recently reduced CPU usage across our fleet by 80%. One key technique that made this possible was a lightweight profiling strategy that we could run in production. This post is about the ways we approached instrumentation, the tradeoffs involved, and some tools you can use to optimize your own apps (including code!).
Background
Nylas is a developer platform that provides APIs to integrate with email, contacts, and calendar. At the core of this is a technology we call the Sync Engine. It’s a large Python application (~30k LOC) which handles syncing via IMAP, SMTP, ActiveSync, and other protocols. The code is open source on GitHub with a solid community.
Suscribirse a:
Entradas (Atom)