Wieder was gelernt

buildozer

2024-12-16 (Monday)
Tags: Python packaging Android iOS Windows OSX Linux

buildozer Buildozer is a tool for creating application packages easily. The goal is to have one “buildozer.spec” file in your app directory, describing your application requirements and settings such as title, icon, included modules etc. Buildozer will use that spec to create a package for Android, iOS, Windows, OSX and/or Linux.

Function Decorators in Python

2024-12-15 (Sunday)
Tags: Python

The description of function decorators in the language reference is quite dense, so I’m teasing it apart here with two examples from 5 Custom Python Decorators For Your Projects by NeuralNine. Decorator without parameters def time_logger(func): def wrapper(*args, **kwargs): start = time.perf_counter() result = func(*args, **kwargs) end = time.perf_counter() print("Time taken:", end - start) return result return wrapper @time_logger def process_input(n): # whatever Decorator expressions are evaluated when the function is defined, in the scope that contains the function definition.

Ruff

2024-11-23 (Saturday)
Tags: Python Formatter Linter

Ruff — An extremely fast Python linter and code formatter, written in Rust.

uv

2024-11-23 (Saturday)
Tags: python package manager

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

Atheris

2023-06-11 (Sunday)
Tags: testing fuzzing Python

Atheris (@ github)

Text Classification Tutorial

2023-05-02 (Tuesday)
Tags: machine learning text classification python

https://developers.google.com/machine-learning/guides/text-classification

Python Database Adapters

2023-01-18 (Wednesday)
Tags: python database postgresql mysql mariadb pep-0249

Database PyPI Debian Ubuntu import Rows as named tuples PostgreSQL psycopg import psycopg import psycopg.rows csr = db.cursor(row_factory=psycopg.rows.namedtuple_row) MySQL/MariaDB mysqlclient python3-mysqldb python3-mysqldb import MySQLdb MySQL/MariaDB mysql-connector n/a python3-mysql.connector import mysql.connector csr = db.cursor(named_tuple=True)

Python Web Framework Cheat Sheet

2022-11-01 (Tuesday)
Tags: Flask FastAPI Django Web Python Programming Reference

Feature Flask FastAPI Django Variable rules in routes <type:variable> [R] Return HTTP error abort(code) [R] Statt dem Code kann man auch ein Response-Objekt angeben, z.B. abort( make_response( jsonify(message="Post not found"), 404 ) ) raise HTTPException(status_code=, detail=, headers=) [R] return HttpResponse(status_code=404) . For some status codes there are also predefined subclasses, so for 404, we can use return HttpResponseNotFound() or even raise Http404()

for … else

2022-10-08 (Saturday)
Tags: Python

https://gitlab.wsr.at/hjp/usradm/-/blob/c75d0b4d551fe94529361703c6e00fa2e4cc4809/old/sync/sync_from_ldap.py#L771 www2023 (not yet committed)

Now in local time zone

2022-03-16 (Wednesday)
Tags: Python Timezones Timestamps

datetime.datetime.now().astimezone()

Python Packaging

2022-03-10 (Thursday)
Tags: python packaging PyPI

Direkt-Installation aus dem Working Directory: pip install . (pip install -e . funktioniert nicht mit setup.cfg, nur mit setup.py) Packages bauen: python3 -m build Uploaden: twine upload dist/*

Python regex

2022-03-09 (Wednesday)
Tags: Python PyPI regex regular expressions

regex is a more capable replacement for re (via LWN)

Python Data Visualization

2021-02-14 (Sunday)
Tags: Python Visualization Bokeh

Bokeh Bokeh Documentation Gallery Getting started with Bokeh

asyncpg

2021-02-02 (Tuesday)
Tags: postgresql python async

asyncpg

Stop Using Print to Debug in Python. Use Icecream Instead

2021-01-18 (Monday)
Tags: python debugging tracing logging icecream introspection

Stop Using Print to Debug in Python. Use Icecream Instead

Python Outlier Detection (PyOD)

2021-01-11 (Monday)
Tags: python statistics machine learning monitoring pyod outlier detection

Python Outlier Detection (PyOD)

A Python Package Developer’s Cheat Sheet

2021-01-04 (Monday)
Tags: python packaging development testing

A Python Package Developer’s Cheat Sheet

These Modern Programming Languages Will Make You Suffer

2020-12-27 (Sunday)
Tags: programming languages comparison C++ Java C# Python Rust TypeScript Go JavaScript Haskell OCaml Scala Elm F# ReasonML Elixir

These Modern Programming Languages Will Make You Suffer TLDR: * Best System Language: Go * Best Language for Fintech: F# * Best Language for Enterprise Software: F# * Best Frontend Language: ReasonML * Best Language for Building Web APIs: Elixir * Best Language for Building Concurrent and Distributed Software: Elixir ReasonML is basically OCaml in new syntax and compiled to JS, so it is the perfect match for React.. Elixir is Erlang with nicer syntax.

Bandit

2020-11-14 (Saturday)
Tags: python bandit security lint static code analysis

Bandit

Checking for resultset in Python DB API

2020-11-06 (Friday)
Tags: python database postgresql psycopg2

(Warning: Only tested with psycopg2) Sometimes you want to execute an SQL query but don’t know whether it will return a resultset in advance. An example would be a psql-like interface where the user can type arbitrary queries (DQL, DML, or DDL) or a very generic interface class. Calling fetchone() or fetchall() raises a ProgrammingError when there is no resultset. We could catch that, but that’s not elegant. Parsing the query to determine whether it should return a resultset is not feasible.

Apache Arrow

2020-11-01 (Sunday)
Tags: data memory format data processing pandas analytics python go javascript

Apache Arrow

MonetDB

2020-09-23 (Wednesday)
Tags: monetdb database column-store embeddable sqlite python

https://www.monetdb.org/

Apache /server-status vs WSGI

2020-09-04 (Friday)
Tags: apache wsgi python monitoring

When writing web applications, it is often necessary (or at least more aesthetic) to make the home page part of the application. Using mod_wsgi, this looks like this: WSGIScriptAlias / /var/www/mysite/app/myapp/myapp/wsgi.py Static files can be exempted via aliases: Alias /robots.txt /var/www/mysite/htdocs/robots.txt Alias /favicon.ico /var/www/mysite/htdocs/favicon.ico Alias /static/ /var/www/mysite/htdocs/static/ If you want to enable mod_status the normal approach doesn’t work: <Location "/server-status"> SetHandler server-status· Require ip 192.0.2.0/24 </Location> /server-status will be passed to WSGI handler instead of the server-status handler, no matter how you arrange the directives.

Virtualenv

2020-07-27 (Monday)
Tags: python pip virtualenv

virtualenv installiert initial folgende Packages: setuptools pkg_resources pip wheel python3 -m venv installiert nicht alle davon. Zumindest muss man nachinstallieren: wheel

Async Python is not faster

2020-06-17 (Wednesday)
Tags: Python Web Performance

Under realistic conditions (see below) asynchronous web frameworks are slightly worse throughput (requests/second) and much worse latency variance. Async Python is not faster

pycallgraph

2020-05-31 (Sunday)
Tags: python development graphviz visualization

Python Call Graph is a Python module that creates call graph visualizations for Python applications.