Install & Compatibility
Where this runs
tested against v0.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 1.6s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
parse
✓ from peppercorn import parse
flatten
✓ from peppercorn import flatten
Demonstrates parsing a flat dictionary (representing form data) into a nested structure and then flattening it back.
import peppercorn
# Example form data, typically from request.form
form_data = {
'items.0.name': 'Foo',
'items.0.value': '123',
'items.1.name': 'Bar',
'items.1.value': '456',
'user.name': 'Alice',
'user.id': 'abc'
}
# Parse flat data into a nested structure
parsed_data = peppercorn.parse(form_data)
print("Parsed Data:", parsed_data)
# Expected: {'items': [{'name': 'Foo', 'value': '123'}, {'name': 'Bar', 'value': '456'}], 'user': {'name': 'Alice', 'id': 'abc'}}
# Flatten a nested structure back into flat form data
# (Often for use in template rendering or re-submitting)
flat_data = peppercorn.flatten(parsed_data)
print("Flattened Data:", flat_data)
# Expected: {'items.0.name': 'Foo', 'items.0.value': '123', 'items.1.name': 'Bar', 'items.1.value': '456', 'user.name': 'Alice', 'user.id': 'abc'}
Errors
Common errors & fixes
AttributeError: module 'peppercorn' has no attribute 'Parse'
Attempting to call `peppercorn.Parse` (PascalCase) instead of `peppercorn.parse` (lowercase). Python function names are typically snake_case.
fixUse `peppercorn.parse` (lowercase) for the parsing function.
My parsed data is flat, but I expected a nested dictionary/list!
The input keys to `peppercorn.parse` did not strictly follow the dot-notation (`parent.child`) or array-indexing (`list.0.item`) conventions, causing `peppercorn` to treat them as literal flat keys.
fixInspect your input dictionary keys. Ensure nested objects use dot-notation and list items use integer indices following the dot (e.g., `items.0.name`).
TypeError: 'dict' object is not subscriptable (when trying to access a list element)
This error often occurs when `peppercorn.parse` creates a dictionary where you expected a list, because the input keys for what should have been list elements were malformed (e.g., `items.first.name` instead of `items.0.name`).
fixVerify that your input keys for list elements use valid integer indices, like `items.0.field`, `items.1.field`, etc., ensuring `peppercorn` correctly identifies and creates a list.
Upgrade
Version history
0.6latest on PyPI · released Aug 24, 2018
Audit
Dependencies
No dependency data recorded yet.