Registry / serialization / paragraphs

paragraphs

JSON →
library1.0.1pypypi✓ verified 84d ago

Paragraphs is a Python library designed to simplify the incorporation of long strings into Python code, making them more readable and maintainable. It provides a simple function to format multi-line strings, aiming to prevent common formatting issues that arise with extensive text blocks in code. The current version is 1.0.1, and its release cadence appears to be infrequent, with the last update in 2019.

pip install paragraphs
INSTALL
IMPORT
SIG · PARAGRAPHS
P
paragraphs
serializationpythonv1.0.1
Install
1.5s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.1 · 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
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

par
from paragraphs import par
import paragraphs; paragraphs.par(...)
The primary utility is the 'par' function, usually imported directly for conciseness.

The `par` function takes a multi-line string (often a triple-quoted string) and formats it, typically by dedenting and re-wrapping it to remove extraneous whitespace and improve readability. This is particularly useful for constructing human-readable messages or documentation within the code.

from paragraphs import par long_text = par( """ This is a very long string that needs to be incorporated into Python code without looking messy. The 'paragraphs' library helps format such text blocks beautifully, handling line breaks and indentation consistently. It's especially useful for error messages, documentation strings, or large text data that needs to be easily editable and readable within the code itself. """ ) print(long_text) # Expected output will be the text, re-wrapped and dedented automatically by 'par'. # The exact wrapping depends on the internal logic of 'par'. # Example of usage within an exception message: class CustomError(Exception): def __init__(self, detail: str): self.detail = detail def __str__(self): return par( f""" An error occurred: {self.detail}. This message is designed to be human-readable and automatically formatted by 'par'. The original issue was due to an unexpected input value. Please review the input and try again. """ ) try: raise CustomError("Invalid configuration file") except CustomError as e: print(e)
Debug
Known issues
gotchaThe `paragraphs` library provides a single `par` function. Its main purpose is to dedent and wrap multiline strings. If you expect more advanced text processing, like natural language paragraph detection or rich text rendering, this is not the correct library; consider `to-paragraphs` or `pyparagraph` respectively.
fix
Ensure `paragraphs` matches your text processing needs. For semantic paragraph detection, try `to-paragraphs`. For Knuth-Plass line-breaking with PIL rendering, look at `pyparagraph`.
affects: All versions
deprecatedThe library has not seen updates since 2019 (version 1.0.1). While its simple functionality might remain stable, active development and compatibility with newer Python features or more complex text formatting needs are not guaranteed.
fix
For mission-critical projects or those requiring active maintenance, evaluate alternatives or consider vendoring the code if its current functionality suffices and no breaking changes are anticipated from Python updates.
affects: <=1.0.1
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'paragraphs'
The 'paragraphs' library has not been installed or is not accessible in the current Python environment.
fix
Install the library using pip: `pip install paragraphs`.
AttributeError: module 'paragraphs' has no attribute 'par'
You are trying to access 'par' as an attribute of the 'paragraphs' module, but it should be imported directly.
fix
Change your import statement from `import paragraphs` to `from paragraphs import par`.
Upgrade
Version history
1.0.1latest on PyPI · released Aug 11, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
16 hits · last 30 days
node
12
Amazon
1
Resources
paragraphs — pip install paragraphs · libregistry