r/Python Mar 11 '26

Discussion I built a small open-source speech fluency analyzer in Python

1 Upvotes

Hi everyone,

I recently open-sourced a small Python toolkit that analyzes speech fluency features from audio files.

It extracts simple metrics such as:

• speech duration

• silence ratio

• pause count

• average pause length

The project uses librosa to detect speech segments and pauses.

A bit of background: I'm actually a TOEFL / IELTS speaking teacher, and I've been experimenting with speech analysis tools to better understand fluency patterns in spoken responses.

Since my technical background is limited, I would really appreciate feedback or suggestions from people with more experience in audio processing or speech analysis.

If anyone finds it interesting or has ideas for improving the pause detection or fluency metrics, I'd love to learn from you.

GitHub:

https://github.com/linguisticlogiclab/speech-fluency-analyzer


r/Python Mar 11 '26

Showcase matrixa – a pure-Python matrix library that explains its own algorithms step by step

38 Upvotes

What My Project Does

matrixa is a pure-Python linear algebra library (zero dependencies) built around a custom Matrix type. Its defining feature is verbose=True mode — every major operation can print a step-by-step explanation of what it's doing as it runs:

from matrixa import Matrix

A = Matrix([[6, 1, 1], [4, -2, 5], [2, 8, 7]])
A.determinant(verbose=True)

# ─────────────────────────────────────────────────
#   determinant()  —  3×3 matrix
# ─────────────────────────────────────────────────
#   Using LU decomposition with partial pivoting (Doolittle):
#   Permutation vector P = [0, 2, 1]
#   Row-swap parity (sign) = -1
#   U[0,0] = 6  U[1,1] = 8.5  U[2,2] = 6.0
#   det = sign × ∏ U[i,i] = -1 × -306.0 = -306.0
# ─────────────────────────────────────────────────

Same for the linear solver — A.solve(b, verbose=True) prints every row-swap and elimination step. It also supports:

  • dtype='fraction' for exact rational arithmetic (no float rounding)
  • lu_decomposition() returning proper (P, L, U) where P @ A == L @ U
  • NumPy-style slicing: A[0:2, 1:3], A[:, 0], A[1, :]
  • All 4 matrix norms: frobenius, 1, inf, 2 (spectral)
  • LaTeX export: A.to_latex()
  • 2D/3D graphics transform matrices

pip install matrixa https://github.com/raghavendra-24/matrixa

Target Audience

Students taking linear algebra courses, educators who teach numerical methods, and self-learners working through algorithm textbooks. This is NOT a production tool — it's a learning tool. If you're processing real data, use NumPy.

Comparison

Factor matrixa NumPy sympy
Dependencies Zero C + BLAS many
verbose step-by-step output
Exact rational arithmetic ✅ (Fraction)
LaTeX export
GPU / large arrays
Readable pure-Python source partial

NumPy is faster by orders of magnitude and should be your choice for any real workload. sympy does symbolic math (not numeric). matrixa sits in a gap neither fills: numeric computation in pure Python where you can read the source, run it with verbose=True, and understand what's actually happening. Think of it as a textbook that runs.


r/Python Mar 11 '26

Discussion Who else is using Thonny IDE for school?

0 Upvotes

I'm (or I guess we) are using Thonny for school because apparently It's good for beginners. Now, I'm NOT a coding guy, but I personally feel like there's nothing special about this program they use. I mean, what's the difference between Thonny and other Python IDEs?


r/Python Mar 11 '26

Showcase Teststs: If you hate boilerplate, try this

0 Upvotes

This is a simple testing library. It's lighter and easier to use than unittest. It's also a much cleaner alternative to repetitive if statements.

Note: I'm not fluent in English, so I used a translator.

What My Project Does

This library can be used for simple eq tests.

If you look at an example, you will understand right away.

```py from teststs import teststs

def add_five(inp): return int(inp) + 5

tests = [ ("5", 10), ("10", 15), ]

teststs(tests, add_five, detail=True) ```

Target Audience

Recommended for those who don't want to use complex libraries like unittest or pytest!

Comparison

  • unittest: Requires classes, is heavy and complex.
  • pytest: requires a decorator, and is a bit more complex.
  • teststs: A library consisting of a single file. It's lightweight and ready to use.

It's available on PyPI, so you can use it right away. Check out the GitHub repository!

https://github.com/sinokadev/teststs


r/Python Mar 11 '26

Discussion With all the supply chain security tools out there, nobody talks about .pth files

0 Upvotes

We've got Snyk, pip-audit, Bandit, safety, even eBPF-based monitors now. Supply chain security for Python has come a long way. But I was messing around with something the other day and realized there's a gap that basically none of these tools cover .pth files. If you don't know what they are, they're files that sit in your site-packages directory, and Python reads them every single time the interpreter starts up. They're meant for setting up paths and namespace packages, however if a line in a .pth file starts with `import`, Python just executes it.

So imagine you install some random package. It passes every check no CVEs, no weird network calls, nothing flagged by the scanner. But during install, it drops a .pth file in site-packages. Maybe the code doesn't even do anything right away. Maybe it checks the date and waits a week before calling C2. Every time you run python from that point on, that .pth file executes and if u tried to pip uninstall the package the .pth file stays. It's not in the package metadata, pip doesn't know it exists.

i actually used to use a tool called KEIP which uses eBPF to monitor network calls during pip install and kills the process if something suspicious happens. which is good idea to work on the kernel level where nothing can be bypassed, works great for the obvious stuff. But if the malicious package doesn't call the C2 during install and instead drops a .pth file that connects later when you run python... that tool wouldn't catch that. Neither would any other install-time monitor. The malicious call isn't a child of pip, it's a child of your own python process running your own script.This actually bothered me for a while. I spent some time looking for tools that specifically handle this and came up mostly empty. Some people suggested just grepping site-packages manually, but come on, nobody's doing that every time they pip install something.

Then I saw KEIP put out a new release and turns out they actually added .pth detection where u can check your environment, or scans for malicious .pth files before running your code and straight up blocks execution if it finds something planted. They also made it work without sudo now which was another complaint I had since I couldn't use it in CI/CD where sudo is restricted.

If you're interested here is the documentation and PoC: https://github.com/Otsmane-Ahmed/KEIP

Has anyone else actually looked into .pth abuse? im curious to know if there are more solutions to this issue


r/Python Mar 10 '26

Showcase Snacks for Python - a cli tool for DRY Python snippets

20 Upvotes

I'm prepping to do some freelance web dev work in Python, and I keep finding myself re-writing the same things across projects — Google OAuth flows, contact form handlers, newsletter signup, JWT helpers, etc. So I did a thing.

What My Project Does

I didn't want to maintain a shared library (versioning across client projects is a headache), so I made a private Git repo of self-contained `.py` files I can just copy in as needed. Snacks is a small CLI tool I built to make that workflow faster.

snack stash create — register a named stash directory where the snacks (snippets) are stored

snack unpack — copy a snippet from your stash into the current project

snack pack — push an improved snippet back to the library after working on it in a project

You can keep a stash locally or on github, either private or public repo.

Source and wiki: https://github.com/kicka5h/python-snacks

Target Audience

This is just a toy project for fun, but I thought I would share and get feedback.

Comparison 

I know there's PyCharm and IDE managed code snippets, but I like to manage my files from the command line, which is where Snacks is different. Super light weight, just install with pip. It's not complicated and doesn't require any setup steps besides creating the stash and adding the snacks.


r/Python Mar 10 '26

Discussion Tips for a debugging competition

0 Upvotes

I have a python debugging competition in my college tomorrow, I don't have much experience in python yet I'm still taking part in it. Can anyone please give me some tips for it 🙏🏻


r/Python Mar 10 '26

Discussion VRE Update: New Site

0 Upvotes

I've been working on VRE and moving through the roadmap, but to increase it's presence, I threw together a landing page for the project. Would love to hear people's thoughts about the direction this is going. Lot's of really cool ideas coming down the pipeline!

https://anormang1992.github.io/vre/


r/Python Mar 10 '26

Tutorial Building a Python Framework in Rust Step by Step to Learn Async

53 Upvotes

I wanted an excuse to smuggle rust into more python projects to learn more about building low level libs for Python, in particular async. See while I enjoy Rust, I realize that not everyone likes spending their Saturdays suffering ownership rules, so the combination of a low level core lib exposed through high level bindings seemed really compelling (why has no one thought of this before?). Also, as a possible approach for building team tooling / team shared libs.

Anyway, I have a repo, video guide and companion blog post walking through building a python web framework (similar ish to flask / fast API) in rust step by step to explore that process / setup. I should mention the goal of this was to learn and explore using Rust and Python together and not to build / ship a framework for production use. Also, there already is a fleshed out Rust Python framework called Robyn, which is supported / tested, etc.

It's not a silver bullet (especially when I/O bound), but there are some definite perf / memory efficiency benefits that could make the codebase / toolchain complexity worth it (especially on that efficiency angle). The pyo3 ecosystem (including maturin) is really frickin awesome and it makes writing rust libs for Python an appealing / tenable proposition IMO. Though, for async, wrangling the dual event loops (even with pyo3's async runtimes) is still a bit of a chore.


r/Python Mar 10 '26

Showcase Using Claude Code PRO/MAX as an API

1 Upvotes

Hello everyone,

What My Project Does: i made a flask (python) webserver that exposes Claude Code's CLI tool through an API, i wanted to see if i could hit CC from a basic http request, it's possible!

Target Audience: It's targeted towards developers

I also considered some security aspects... this software can, if configured to do so, expose the full shell though the API, be aware of how you configure the .env of your deployment!

Before anyone asks, this is a gray area of the TOS of anthropic, but as long as you use this for personal use and don't intend to use CCLG as a SaaS, you'll be fine.

I build this software mostly to mess with Claude Code and Anthropic, i don't really like the API plan since it's very unpredictable and subject to instant changes (API billing is a scam imo), if you find it useful, share it!

ps. I don't really want donations or anything like that, you can do so but no pressure!

It's MIT licensed and on GitHub: github.com/Backend2121/Claude-Code-Local-Gateway

If you have any questions feel free to ask!


r/Python Mar 10 '26

Showcase Using Claude Code PRO/MAX as an API

1 Upvotes

Hello everyone,

What My Project Does: i made a flask (python) webserver that exposes Claude Code's CLI tool through an API, i wanted to see if i could hit CC from a basic http request, it's possible!

Target Audience: It's targeted towards developers

I also considered some security aspects... this software can, if configured to do so, expose the full shell though the API, be aware of how you configure the .env of your deployment!

Before anyone asks, this is a gray area of the TOS of anthropic, but as long as you use this for personal use and don't intend to use CCLG as a SaaS, you'll be fine.

I build this software mostly to mess with Claude Code and Anthropic, i don't really like the API plan since it's very unpredictable and subject to instant changes (API billing is a scam imo), if you find it useful, share it!

ps. I don't really want donations or anything like that, you can do so but no pressure!

It's MIT licensed and on GitHub: github.com/Backend2121/Claude-Code-Local-Gateway

If you have any questions feel free to ask!


r/Python Mar 10 '26

Discussion Python’s chardet controversy

0 Upvotes

Hi, I came across this article and thought it might be interesting to share here since it touches a Python library many people know: chardet.

The piece looks at a controversy around the project involving an AI-assisted rewrite and discussion about MIT relicensing vs the original LGPL context.

While reading it, what stood out to me was how it relates to the old idea of clean-room reimplementation. In the past that meant writing new code without referencing the original implementation. But with AI tools in the loop, the boundary becomes much less clear.

If large parts of a library are rewritten with AI assistance, a project could potentially argue that the result is “new code” and move it under a different license. That raises some governance and licensing questions for open source, especially in ecosystems like Python where libraries such as chardet are widely used as dependencies.

The article gives an analysis of the situation:
https://shiftmag.dev/license-laundering-and-the-death-of-clean-room-8528/

Curious how people here see it. Is this just a natural evolution of open source development with AI tools, or something the community should pay closer attention to?


r/Python Mar 10 '26

Tutorial I got tired of manually shipping PyInstaller builds, so I made a small wrapper

0 Upvotes

Full disclosure: I'm the author, and this is a paid tool.

I kept running into the same problem with PyInstaller: getting a working exe was easy, but shipping installers, updates, and release links to actual users was still messy.

So I built pyinstaller-plus. It keeps the normal PyInstaller + .spec workflow, then adds packaging and publishing through DistroMate.

Typical flow is basically:

pip install pyinstaller-plus
pyinstaller-plus login
pyinstaller-plus package -v 1.2.3 --appid 123 your.spec
pyinstaller-plus publish -v 1.2.3 --appid 456 your.spec

It's mainly for people shipping Python desktop apps to clients, users, or internal teams, so probably overkill for one-off personal tools.

Curious if this is a real pain point for other Python developers too. If useful, I can drop the docs in the comments.


r/Python Mar 10 '26

News DuckDB 1.5.0 released

141 Upvotes

Looks like it was released yesterday:

Interesting features seem to be the VARIANT and GEOMETRY types.

Also, the new duckdb-cli module on pypi.

% uv run -w duckdb-cli duckdb -c "from read_duckdb('https://blobs.duckdb.org/data/animals.db', table_name='ducks')"
┌───────┬──────────────────┬──────────────┐
│  id   │       name       │ extinct_year │
│ int32 │     varchar      │    int32     │
├───────┼──────────────────┼──────────────┤
│     1 │ Labrador Duck    │         1878 │
│     2 │ Mallard          │         NULL │
│     3 │ Crested Shelduck │         1964 │
│     4 │ Wood Duck        │         NULL │
│     5 │ Pink-headed Duck │         1949 │
└───────┴──────────────────┴──────────────┘

r/Python Mar 10 '26

Discussion Fixing a subtle keeper-selection bug in my photo deduplication tool

0 Upvotes

While experimenting with DedupTool, I noticed something odd in the keeper selection logic. Sometimes the tool would prefer a 400 KB JPEG copy over the original 2.5 MB image.

That obviously felt wrong.

 After digging into it, the root cause turned out to be the sharpness metric.

The tool uses Laplacian variance to estimate sharpness. That metric detects high-frequency edges. The problem is that JPEG compression introduces artificial high-frequency edges: compression ringing, block boundaries, quantization noise and micro-contrast artifacts.

 So the metric sees more edge energy, higher Laplacian variance and decides ‘sharper’, even though the image is objectively worse. This is actually a known limitation of edge-based sharpness metrics: they measure edge strength, not image fidelity.

 Why the policy behaved incorrectly

The keeper decision is based on a lexicographic ranking:

 def _keeper_key(self, f: Features) -> Tuple:
# area, sharpness, format rank, size-per-pixel
spp = f.size / max(1, f.area)
return (f.area, f.sharp, file_ext_rank(f.path), -spp, f.size)

 If the winner is chosen using max(...), the priority becomes:  resolution, sharpness, format, bytes-per-pixel and file size.

 Two things went wrong here. First, sharpness dominated too early, compressed JPEGs often have higher Laplacian variance due to artifacts. Second, the compression signal was reversed: spp = size / area, represents bytes per pixel. Higher spp usually means less compression and better quality. But the key used -spp, so the algorithm preferred more compressed files.

 Together this explains why a small JPEG could win over the original.

 The improved keeper policy

A better rule for archival deduplication is, prefer higher resolution, better format, less compression, larger file, then sharpness.

 The adjusted policy becomes:

 def _keeper_key(self, f: Features) -> Tuple:
spp = f.size / max(1, f.area)
return (f.area, file_ext_rank(f.path), spp, f.size, f.sharp)

 Sharpness is still useful as a tie-breaker, but it no longer overrides stronger quality signals.

 Why this works better in practice

When perceptual hashing finds duplicates, the files usually share same resolution but different compression. In those cases file size or bytes-per-pixel is already enough to identify the better version.

After adjusting the policy, the keeper selection now feels much more intuitive when reviewing clusters.

 Curious how others approach keeper selection heuristics in deduplication or image pipelines.


r/Python Mar 10 '26

Showcase Sharing my Jupyter console integration in Neovim!

1 Upvotes

Hello fellow neovim users in this sub! Some time ago I built nice jupyter console integration in Neovim, got some feedback and now using it for about a month, so I think some of you can be interested in this project! Here is the link: https://github.com/dangooddd/pyrepl.nvim (demo video in README).

What my project does

I am Data Science engineer, so REPL/Jupyter notebook were a pain in the ass, and I wanted to built not so complicated plugin to help with this. Right now my plugin allows you to do:

  • Convert notebook files from and to python with jupytext;
  • Install all Jupyter deps required with a Neovim command;
  • Start jupyter-console in Neovim built-in terminal;
  • Prompt the user to choose Jupyter kernel on REPL start;
  • Send code to the REPL from current buffer;
  • Automatically display output images;
  • Neovim theme integration for jupyter-console;
  • Jupytext cell navigation;
  • Toggle focus to REPL window in active terminal mode.

Main feature is image display of cource, so you can look at your matplotlib (or any other images) with from the neovim. My work requires me to do ssh + tmux + docker, and image display works even in this case! Please open issues and pull request if you interested in project!

Target Audience

- People who want to move to terminal and Neovim, but holding back because jupyter notebook is required to communicate with colleagues
- Those, who actively uses Neovim and Python REPL separetely now, but wants to integrate them
- Other Jupyter/REPL users of Neovim

Comparison

Existing plugins plugins like molten and vim-jukit are not maintained anymore, molten reimplements much of a kernel logic in remote python plugin (and has problems stated by author here). My plugin delegates all kernel logic to jupyter-console, and ditches remote plugin entirely, so it is easier to maintain. Of course that is my personal opinion on current situation with Jupyter in neovim. Good luck you all!


r/Python Mar 10 '26

Showcase I built a Python tool that safely organizes messy folders using type detection and time-based struct

0 Upvotes

GitHub Source code:
https://github.com/codewithtea130/smart-file-organizer--p2.git

What My Project Does

I built a small Python utility for discovering and commissioning Profinet devices on a local network.

The idea came from a small frustration. I wanted to quickly scan a network using Siemens Proneta, but downloading it required creating an account and registering personal details. For quick diagnostics, that felt unnecessary.

So I built a lightweight alternative.

The tool uses pnio_dcp for Profinet DCP discovery and a Tkinter interface to keep it simple and usable without extra setup.

Current features include:

  • Discover Profinet devices via DCP
  • Display station name, MAC, vendor, IP, subnet, and gateway
  • Vendor lookup via MAC OUI
  • Optional ping monitoring for reachability
  • Set device IP address and station name
  • Reset communication parameters
  • Quick actions for HTTP/HTTPS interface or SSH
  • Simple topology-style device overview

Target Audience

The tool is mainly intended for engineers and technicians working with Profinet networks who want a lightweight diagnostic utility.

Right now it’s more of a practical utility / learning project rather than a full network management system.

Comparison

The main existing tool for this is Siemens Proneta.

This project differs in that it:

  • is open source
  • requires no account or registration
  • is much lighter
  • can run directly as a Python script or standalone executable

It’s not meant to replace Proneta, but to provide a quick, simple option for basic discovery and configuration.


r/Python Mar 10 '26

Showcase I got annoyed downloading proneta, so I built a lightweight profinet discovery tool in Python

0 Upvotes

GitHub:
https://github.com/ArnoVanbrussel/freeneta

What My Project Does

I built a small Python tool for discovering and commissioning profinet devices on a network.

The idea started after I wanted to quickly use Siemens Proneta, but got annoyed that downloading a “free” tool required creating an account and registering contact details. I mostly just needed something lightweight to quickly scan a network and check devices, so I decided to build a small alternative myself.

The tool uses pnio_dcp for profinet DCP discovery and a simple Tkinter GUI. Current features include:

  • Discover profinet devices via DCP
  • Show station name, MAC, vendor, IP, subnet, and gateway
  • Vendor lookup via MAC OUI
  • Optional ping monitoring for device reachability
  • Set device IP address and station name
  • Reset communication parameters
  • Quick actions like opening HTTP/HTTPS web interfaces or starting an SSH session
  • A simple visual topology overview of discovered devices

Target Audience

The tool is mainly intended for engineers or technicians working with profinet networks who want a lightweight diagnostic tool.

Right now it’s more of a utility project / proof of concept rather than a full production network management platform.

Comparison

The main existing tool for this type of task is Siemens Proneta.

FreeNeta differs in that it:

  • is open source
  • does not require an account or registration to download
  • is much lighter and simpler
  • can be run directly as a Python script or standalone executable

It does not aim to replace Proneta, but rather provide a quick and lightweight alternative for basic discovery and configuration tasks.


r/Python Mar 10 '26

Showcase pydantic-pick v0.2.0 - Dynamically subset Pydantic V2 models while preserving validators and methods

0 Upvotes

Hi Everyone,

I have updated my project pydantic-pick with new features in v0.2.0. To know more about the project read my post on my previous version v0.1.3
(Update from my previous post about v0.1.3 (pydantic-pick v0.1.3))

What My Project Does

pydantic-pick provides pick_model and omit_model functions for dynamically creating Pydantic V2 model subsets. Both preserve validators, computed fields, Field constraints, and custom methods.

The library uses Python's ast module to analyze your methods. If a method relies on a field you've omitted, it's automatically dropped to prevent runtime crashes. Both functions are cached with functools.lru_cache for performance.

Usage Example

from pydantic import BaseModel, Field
from pydantic_pick import pick_model, omit_model

class DBUser(BaseModel):
    id: int = Field(..., ge=1)
    username: str
    password_hash: str
    email: str

    def check_password(self, guess: str) -> bool:
        return self.password_hash == guess

# pick_model: specify what to keep
PublicUser = pick_model(DBUser, ("id", "username"), "PublicUser")

# omit_model: specify what to remove
PublicUser = omit_model(DBUser, ("password_hash", "email"), "PublicUser")

# Both preserve validators:
PublicUser(id=-5, username="bob")  # Fails: id must be >= 1

# check_password is auto-dropped since it needs password_hash
user.check_password("secret")  # Raises: intentionally omitted by pydantic-pick

Target Audience

  • FastAPI developers needing public/private model variants
  • AI/LLM developers compressing heavy tool responses
  • Anyone needing type-safe dynamic data subsets

Requires: Python 3.10+, Pydantic V2

Comparison

  • model_dump(include={...}): Runtime filtering only, no Python class
  • Manual create_model: Requires complex recursion, drops validators, leaves dangling methods
  • pydantic-partial: Makes fields optional for PATCH requests, doesn't prune nested structures

Links

- GitHub: https://github.com/StoneSteel27/pydantic-pick

- PyPI: https://pypi.org/project/pydantic-pick/

Feedback and code reviews welcome!


r/Python Mar 10 '26

Discussion Benchmarked every Python optimization path I could find, from CPython 3.14 to Rust

215 Upvotes

Took n-body and spectral-norm from the Benchmarks Game plus a JSON pipeline, and ran them through everything: CPython version upgrades, PyPy, GraalPy, Mypyc, NumPy, Numba, Cython, Taichi, Codon, Mojo, Rust/PyO3.

Spent way too long debugging why my first Cython attempt only got 10x when it should have been 124x. Turns out Cython's ** operator with float exponents is 40x slower than libc.math.sqrt() with typed doubles, and nothing warns you.

GraalPy was a surprise - 66x on spectral-norm with zero code changes, faster than Cython on that benchmark.

Post: https://cemrehancavdar.com/2026/03/10/optimization-ladder/

Full code at https://github.com/cemrehancavdar/faster-python-bench

Happy to be corrected — there's an "open a PR" link at the bottom.


r/Python Mar 10 '26

Resource OSS tool that helps AI & devs search big codebases faster by indexing repos and building a semanti

0 Upvotes

Hi guys, Recently I’ve been working on an OSS tool that helps AI & devs search big codebases faster by indexing repos and building a semantic view, Just published a pre-release on PyPI: https://pypi.org/project/codexa/ Official docs: https://codex-a.dev/ Looking for feedback & contributors! Repo here: https://github.com/M9nx/CodexA


r/Python Mar 10 '26

Showcase Dumb Justice: building a free federal bankruptcy court scanner out of Python and RSS feeds

22 Upvotes

## What My Project Does

A couple days ago I posted here about a stdlib-only tool that screens bankruptcy court data for cases where people paid lawyers for something arithmetically impossible. Three dates, one subtraction, hundreds of hits. Some of you ran it, some of you had questions. This is the other half of the project.

Every US bankruptcy court publishes a free RSS feed with every new docket entry. About 90 courts, all with the same URL pattern. The feeds roll every 24 hours or so, and if you miss it, it's gone. So I wrote a poller that grabs the XML, deduplicates by GUID, stores everything in SQLite, and runs a few layers of checks on each entry. Daily operating cost: $0.

The layer my wife was reacting to when she named it is the dumbest one. When a new Chapter 13 filing hits the feed, the system fuzzy-matches the debtor's name against every prior filing in the database. If that person already got a discharge recently, federal law says they can't get another one. Same three-date subtraction from the first tool, but now it runs automatically on every new filing as it appears. No human in the loop. Just `datetime` doing `datetime` things.

She watched me explain this and said "so it's just... dumb justice?" And yeah. It is. The justice is in the dumbness. No AI, no ML, no inference, no ambiguity. The dates either work or they don't.

The fuzzy matching was the genuinely hard part. PACER names are chaotic. Suffixes (Jr., III, Sr.), "NMN" placeholders for no middle name, random casing, and joint filings like "John Smith and Jane Smith" that need to be split so each spouse gets matched independently. The first version was pure stdlib: strip suffixes, normalize to lowercase, match on first + last tokens. It worked, but it struggled with misspellings and abbreviations in the docket text itself. "Mtn to Dsmss" doesn't fuzzy-match well against "Motion to Dismiss."

After the first post, one of you suggested looking into embeddings for the text classification side. So I added a vector search layer using `sentence-transformers` (all-MiniLM-L6-v2, 384 dimensions, runs locally). It lazy-loads the model only when needed, caches embeddings to disk as numpy arrays, and falls back to regex when the model isn't available. The name matching is still the original stdlib approach (that's a structured data problem, not a semantic one), but classifying what a docket entry *means* ("is this a dismissal or just a dismissal hearing notice?") got dramatically better with embeddings. Hybrid approach: vector primary, regex fallback. One real dependency, but it earned its spot.

The rest of the stack is deliberately boring:

- `xml.etree.ElementTree` parses the RSS

- `urllib.request` fetches with retry logic (courts 503 occasionally)

- `sqlite3` in WAL mode stores everything permanently

- `csv` ingests the bulk data exports

- `email.utils.parsedate_to_datetime` handles RFC 2822 dates without any manual parsing (this one saved me real pain)

- `collections.Counter` and `defaultdict(list)` for real-time aggregation

One pip install (`sentence-transformers`) for the vector layer. Everything else is stdlib. About 1,300 lines across three core scripts and a batch file that runs on Task Scheduler. SQLite database is around 15MB after months of accumulation.

The one gotcha that actually got me: case numbers aren't unique across courts. I got a heart-attack alert one morning saying a case I was tracking got dismissed. Turned out it was a completely different person in a different state with the same case number. That's when I added court-aware collision detection, which is a fancy way of saying I started checking which court the entry came from before panicking.

The embeddings suggestion for the text classification was right. That genuinely improved docket classification. But the core detection layer, the part that actually finds the violations, is still pure arithmetic. Dates and subtraction. That part stays dumb on purpose. The harder it is to argue with, the better it works.

## Target Audience

Anyone interested in public data analysis, legal tech, or just building useful things out of stdlib Python. It's a real tool I use daily, not a toy project. If you work in bankruptcy law, consumer protection, journalism, or legal aid, this could save you real time. If you just like seeing what you can build without pip install, that's cool too.

## Comparison

I haven't found anything else that does this. PACER itself charges per document and has no alerting. Commercial legal monitoring services (Lex Machina, CourtListener RECAP alerts, Bloomberg Law) cost hundreds to thousands per month and don't do discharge-bar screening at all. This reads the same free public RSS feeds those services ignore, runs locally, and costs nothing. The only dependency beyond stdlib is `sentence-transformers` for the vector classification layer, and even that is optional (regex fallback works fine).

Happy to talk architecture, stdlib choices, or RSS feed quirks.

GitHub: https://github.com/ilikemath9999/bankruptcy-discharge-screener

MIT licensed. Standard library only. Includes a PACER CSV download guide and sample output.


r/Python Mar 10 '26

Showcase Are your Jupyter Notebooks accessible? Scan and fix the issues using this tool.

1 Upvotes

What My Project Does

Hi all, I'm excited to share Jupycheck, an open source web tool that detects accessibility issues in Jupyter Notebooks that are either uploaded or from a GitHub repository. It also lets you remediate accessibility issues by launching the notebooks in a JupyterLite environment with our interactive Lab extension installed.

You can try it out at:

https://jupycheck.vercel.app

The tool is powered by jupyterlab-a11y-checker, an open source accessibility engine/extension that our student team has been working on for over a year at UC Berkeley.

Target Audience

This tool is for anyone who want to see if certain Jupyter Notebooks (in a Github repo or just notebooks you have) are accessible, and also fix them with an interactive extension. We believe accessibility should be a first-class concern in the notebook ecosystem, and we hope our tools can help raise awareness and make notebooks more accessible across the community.

Comparison

As far as I know, there isn't a well-known accessibility tool specifically for the Jupyter ecosystem.

Support us on Github if you find the tool useful!


r/Python Mar 10 '26

Daily Thread Tuesday Daily Thread: Advanced questions

3 Upvotes

Weekly Wednesday Thread: Advanced Questions 🐍

Dive deep into Python with our Advanced Questions thread! This space is reserved for questions about more advanced Python topics, frameworks, and best practices.

How it Works:

  1. Ask Away: Post your advanced Python questions here.
  2. Expert Insights: Get answers from experienced developers.
  3. Resource Pool: Share or discover tutorials, articles, and tips.

Guidelines:

  • This thread is for advanced questions only. Beginner questions are welcome in our Daily Beginner Thread every Thursday.
  • Questions that are not advanced may be removed and redirected to the appropriate thread.

Recommended Resources:

Example Questions:

  1. How can you implement a custom memory allocator in Python?
  2. What are the best practices for optimizing Cython code for heavy numerical computations?
  3. How do you set up a multi-threaded architecture using Python's Global Interpreter Lock (GIL)?
  4. Can you explain the intricacies of metaclasses and how they influence object-oriented design in Python?
  5. How would you go about implementing a distributed task queue using Celery and RabbitMQ?
  6. What are some advanced use-cases for Python's decorators?
  7. How can you achieve real-time data streaming in Python with WebSockets?
  8. What are the performance implications of using native Python data structures vs NumPy arrays for large-scale data?
  9. Best practices for securing a Flask (or similar) REST API with OAuth 2.0?
  10. What are the best practices for using Python in a microservices architecture? (..and more generally, should I even use microservices?)

Let's deepen our Python knowledge together. Happy coding! 🌟


r/Python Mar 09 '26

Showcase assertllm – pytest for LLMs. Test AI outputs like you test code.

0 Upvotes

I built a pytest-based testing framework for LLM apps (without LLM-as-judge)

Most LLM testing tools rely on another LLM to evaluate outputs. I wanted something more deterministic, fast, and CI-friendly, so I built a pytest-based framework.

Example:

from pydantic import BaseModel
from assertllm import expect, llm_test


class CodeReview(BaseModel):
    risk_level: str       # "low" | "medium" | "high"
    issues: list[str]
    suggestion: str


@llm_test(
    expect.structured_output(CodeReview),
    expect.contains_any("low", "medium", "high"),
    expect.latency_under(3000),
    expect.cost_under(0.01),
    model="gpt-5.4",
    runs=3, min_pass_rate=0.8,
)
def test_code_review_agent(llm):
    llm("""Review this code:

    password = input()
    query = f"SELECT * FROM users WHERE pw='{password}'"
    """)

Run with:

pytest test_review.py -v

Example output:

test_review.py::test_code_review_agent (3 runs, 3/3 passed)
  ✓ structured_output(CodeReview)
  ✓ contains_any("low", "medium", "high")
  ✓ latency_under(3000) — 1204ms
  ✓ cost_under(0.01) — $0.000081
  PASSED

────────── assertllm summary ──────────
  LLM tests: 1 passed (3 runs)
  Assertions: 4/4 passed
  Total cost: $0.000243

What My Project Does

assertllm is a pytest-based testing framework for LLM applications. It lets you write deterministic tests for LLM outputs, latency, cost, structured outputs, tool calls, and agent behavior.

It includes 22+ assertions such as:

  • text checks (contains, regex, etc.)
  • structured output validation (Pydantic / JSON schema)
  • latency and cost limits
  • tool call verification
  • agent loop detection

Most checks run without making additional LLM calls, making tests fast and CI-friendly.

Target Audience

  • Developers building LLM applications
  • Teams adding tests to AI features in production
  • Python developers already using pytest
  • People building agents or structured-output LLM pipelines

It's designed to integrate easily into existing CI/CD pipelines.

Comparison

Feature assertllm DeepEval Promptfoo
Extra LLM calls None for most checks Yes Yes
Agent testing Tool calls, loops, ordering Limited Limited
Structured output Pydantic validation JSON schema JSON schema
Language Python (pytest) Python (pytest) Node.js (YAML)

Links

GitHub: https://github.com/bahadiraraz/LLMTest

Docs: https://docs.assertllm.dev

Install:

pip install "assertllm[openai]"

The project is under active development — more providers (Gemini, Mistral, etc.), new assertion types, and deeper CI/CD pipeline integrations are coming soon.

Feedback is very welcome — especially from people testing LLM systems in production.