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.1

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.1
File Size Uploaded
packd-0.1.1.tar.gz 52.8 kB Details

Built distribution (wheel)

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

Total release size: 56.5 kB

Release files / packd-0.1.1.tar.gz

Download URL packd-0.1.1.tar.gz
Size 52.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d97cc80df1c8a2ebec88a5810f44ff04ef690713562d6cbf31daaccf6bfdbb54
BLAKE2b-256 checksum
How to use checksums
01fe0dfdf5ffa2110a6e509dcc5d19849b47eed1cb56bde62b3dfae33cf52cca
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.1-py3-none-any.whl

Download URL packd-0.1.1-py3-none-any.whl
Size 3.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2d522f5ecea2f6b2e8a8872e793e94c933f63127f8878ef236d6ed4a735c5281
BLAKE2b-256 checksum
How to use checksums
45e824b49fa56b1234ee50d1411dc9cf0591ec7f86dd4a5966ccc53eb8e3cb68
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

0.1.2

2 release files

This release

0.1.1 This release

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