Link to this headingPython

Generate Executables from python
Streaming to Chromecast with Python
Impacket is a collection of Python classes for working with network protocols.

Cool Libs:

Link to this headingitertools

Source

Link to this headingFix 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 .

Link to this headingUV

An extremely fast Python package and project manager, written in Rust.

Common Commands:

uv --outdated uv update uv add pytest==8.4.0 --no-sync uv remove pytest==8.4.0 --no-sync

Link to this headingtime

Date time with timezones aware:

from datetime import datetime, timezone dt = datetime.now(timezone.utc)

Link to this headingVirtual 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 }

Link to this headingSlots 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

Link to this headingAdvanced

Link to this headingMatch

# Using OR pattern (|) to match multiple patterns match day: case ("Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday"): return "Weekday" case "Saturday" | "Sunday": return "Weekend"

Link to this headingfstrings

print(f"{' [ Run Status ] ':=^50}") print(f"[{time:%H:%M:%S}] Training Run {run_id=} status: {progress:.1%}") print(f"Summary: {total_samples:,} samples processed") print(f"Accuracy: {accuracy:.4f} | Loss: {loss:#.3g}") print(f"Memory: {memory / 1e9:+.2f} GB") #=================== [ Run Status ] =================== #[11:16:37] Training Run run_id=42 status: 87.4% #Summary: 12,345,678 samples processed #Accuracy: 0.9876 | Loss: 0.0123 #Memory: +2.75 GB