What Are Context Managers in Python?
What is a Context Manager in Python?
According to the Python glossary, a context manager is —
An object which controls the environment seen in a with statement by defining enter() and exit() methods.
What is a Context Manager in Python?
According to the Python glossary, a context manager is —
An object which controls the environment seen in a with statement by defining enter() and exit() methods.
TLTR: gunicorn
for WSGI app (like Flask), uvicorn
for ASGI app (like FastAPI)
This is a test how fast we can search value in a very large list
of dict
by various way
When we want to stop ffmpeg
stream recording on Windows programmatically, these sollution will not work:
# asume p is the subprocess.Popen command call ffmpeg
os.kill(p.pid, signal.CTRL_C_EVENT) # parent process get kill too, recording file is not playable
# or
p.terminate() # not good, recording file is not playable
# or
p.send_signal(signal.CTRL_C_EVENT) # parent process get kill too, recording file is not playable
A test logs how Odoo process modules dependency with different install order
Test source code: https://github.com/NothingCtrl/odoo_super_dep_test
For unkown reason, python webserver return MimeType text/plain
for all .js
file when running under Windows 10
There are many ways to find bugs in Python code: the built-in debugger (pdb), a healthy amount of unit tests, a debugger in an IDE like Pycharm or Visual Studio, try/catch
statements, if/else
statements, assert statements
, or the tried and true practice of covering every inch of your codebase in print()
statements like it’s going out of style.
Assert statements can help us catch bugs quickly and are far less intrusive than copious amounts of print
statements. However, unlike print
statements, assert statements can be unexpectedly risky to use!
This article explores how to use asserts safely and what causes them to be unsafe. By the end of this article, you’ll know how to use assert
most optimally without inadvertently opening yourself up to security issues.