Skip to main content

I don't like multi-line dictionaries. They're ugly, take up too much space, and distract me from the real logic in the code. I could put it all on one line but then that would break line length convention and be unreadable. In most dictionaries only a few values vary and the rest are constants you type once. This package moves those values into a template you declare once, leaving the call site with just what changes. Nothing crazy, just a small OCD annoyance solved.

Usage

from packd import packd, template

@template
def conn(host: str, port: int, *, timeout: int = 30, ssl: bool = True): ...

packd("conn", "localhost", 5432)
# {"host": "localhost", "port": 5432, "timeout": 30, "ssl": True}

Parameters before the asterisk are passed in, matched by position. Keyword parameters are filled from their defaults, and can be overriden per call.ridden per call:

packd("conn", "localhost", 5432, timeout=5)

Output Keys

Sometimes you need to alias the keys in your dictionary, so you can either convert them to a case found in the CaseEnum class or alias them individually. You can do both, the alias always wins.

from packd import CaseEnum

@template(case=CaseEnum.CAMEL, aliases={"content_type": "Content-Type"})
def headers(token: str, *, content_type: str = "application/json", read_timeout: int = 30): ...

packd("headers", "supersecrettoken")
# {"token": "abc", "Content-Type": "application/json", "readTimeout": 30}

Quick Note

The templates register on import, so a template in a file nothing imports won't be found.

Metadata

Release files for packd 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for packd 0.1.2
File Size Uploaded
packd-0.1.2.tar.gz 53.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for packd 0.1.2
File Interpreter ABI Platform
packd-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 57.1 kB

Release files / packd-0.1.2.tar.gz

Download URL packd-0.1.2.tar.gz
Size 53.1 kB
Tags Source
SHA-256 checksum
How to use checksums
50c0c7bedef99c7a42ca1a97ae3588cc6aa4252e07835271519cc856d1155d64
BLAKE2b-256 checksum
How to use checksums
466f6a53e2ea79606a2655720422e6a1ad1ca2b1b645beced83d7e268b119bff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / packd-0.1.2-py3-none-any.whl

Download URL packd-0.1.2-py3-none-any.whl
Size 4.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fa8b16d4f7e4580841cbda678dc2e9efec087e3a88f5db944607f9d26442ed2c
BLAKE2b-256 checksum
How to use checksums
90dfa2871a4ed2a0d3750f790cf9058f527af0dea7aed95de08c9248e9c6ae26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page