Python
Links
- Force restart faild Gunicor service
- Cookiecutter Django
- Django language codes
- All language codes
- Django reverse Many2Many inline admin
- Django <=> Python
- Django value sensitive unique together
- DRF serialzer write only fields
- Locale error: unsupported locale setting
- Locale problem in Docker
- Celery timezone types
- Python date types
- Convert Python file to .exe
- Time complexity (big O)
- Number of Gunicorn workers in Kubernetes
- 3rd-party Python profiler
- Clean code python book
- FastAPI & Poetry standard Dockerfile
- Bypass Cloudflare protection
File
Class & Function
-
Get full path:
import os import inspect def foo(): pass print(os.path.abspath(inspect.getfile(foo))) class Bar: pass print(os.path.abspath(inspect.getfile(Bar.__class__)))
Modules & Packages
-
Get all import able modules & packages:
import pkgutil search_path = ['.'] # set to None to see all modules importable from sys.path all_modules = [x[1] for x in pkgutil.iter_modules(path=search_path)] print(all_modules)
Celery
-
Kill celery process:
kill -9 $(ps aux | grep celery | grep -v grep | awk '{print $2}' | tr '\n' ' ') > /dev/null 2>&1
-
View worker logs:
celery -A <worker name: karestoon> worker --loglevel=info
PIP
-
Install from source (Unix path):
pip install file:///path/to/package
Operators
-
Overview
-
The "i" symbol means "in place"
- The "a" symbol means "asynchronous"
- The "r" symbol means "reverse"
- When we are implementing the "Rich comparison" method we should return a new object, in the other hand for the "Augmented assignment arithmetic" method we should update the current object