Python
Python¶
Generate Executables from python
Streaming to Chromecast with Python
Impacket is a collection of Python classes for working with network protocols.
itertools¶
Fix errors like imports etc¶
/home/generalzero/.local/bin/ruff check spotify_*.py
spotify_.py:8:89: E501 Line too long (125 > 88 characters)
ruff check --fix .
Itter tools¶
https://docs.python.org/3/library/itertools.html#itertools.batched
time¶
Date time with timezones aware
from datetime import datetime, timezone
dt = datetime.now(timezone.utc)
Virtual Environments¶
Making requirements.txt:
pip freeze > requirements.txt
Venv Script:
venv (){
if [ "$#" -eq "0" ]; then
echo "Usage: venv env_name"
else
#Check if $1 directory exists
if [ ! -d "${HOME}/.venv/$1" ]; then
python -m venv "${HOME}/.venv/$1"
fi
source "${HOME}/.venv/$1/bin/activate"
fi
}
Slots in Classes¶
Using slots can decrease the memory usage of classes. But remove the ability to add new class objects later.
https://wiki.python.org/moin/UsingSlots