Formatted Join ✅
Effortlessly join string sequences with flexible separator formatting for clear, polished output
Installation
PyPI
pip install formatted-join
uv
uv add formatted-join
Usage Examples
formatted_join(items: Sequence[str], separator=', ', final_separator=' and ', use_penultimate_separator=True) -> str
Joins items with flexible separator configuraton.
>>> from formatted_join import formatted_join
>>> formatted_join(['Hello', 'World'])
'Hello and World'
>>> formatted_join(('A', 'B', 'C'))
'A, B, and C'
>>> formatted_join(['X', 'Y', 'Z', 'W'], separator=' | ', final_separator=' & ')
'X | Y | Z & W'
>>> formatted_join(['Solo'])
'Solo'
>>> formatted_join(['', ''])
' and '
>>> formatted_join(
... items=['Alpha', 'Bravo', 'Charlie', 'Delta'],
... separator=' | ',
... final_separator=' & ',
... use_penultimate_separator=False
... )
'Alpha | Bravo | Charlie & Delta'
>>> formatted_join(['One', 'Two'], final_separator=' ~ ')
'One ~ Two'
formatted_join_conjunction(items: Sequence[str], language: str = 'en') -> str
Joins items using a comma and localized* “and” before the last item.
>>> from formatted_join import formatted_join_conjunction
>>> formatted_join_conjunction(['Spring', 'Summer'])
'Spring and Summer'
>>> formatted_join_conjunction(['One', 'Two', 'Three'])
'One, Two, and Three'
>>> formatted_join_conjunction(['Motorcycle', 'Bus', 'Car'], language='en')
'Motorcycle, Bus, and Car'
>>> formatted_join_conjunction(['Motorcycle', 'Bus', 'Car'], language='de')
'Motorcycle, Bus und Car'
formatted_join_disjunction(items: Sequence[str], language: str = 'en') -> str
Joins items using a comma and localized* “or” before the last item.
>>> from formatted_join import formatted_join_disjunction
>>> formatted_join_disjunction(['Monday', 'Tuesday'])
'Monday or Tuesday'
>>> formatted_join_disjunction(['X', 'Y', 'Z'])
'X, Y, or Z'
>>> formatted_join_disjunction(['Motorcycle', 'Bus', 'Car'], language='en')
'Motorcycle, Bus, or Car'
>>> formatted_join_disjunction(['Motorcycle', 'Bus', 'Car'], language='de')
'Motorcycle, Bus oder Car'
formatted_join_unit(items: Sequence[str]) -> str
Joins items with commas only (no distinct final separator).
>>> from formatted_join import formatted_join_unit
>>> formatted_join_unit(['A'])
'A'
>>> formatted_join_unit(['A', 'B', 'C', 'D'])
'A, B, C, D'
formatted_join_narrow(items: Sequence[str]) -> str
Joins items with a single space separating each.
>>> from formatted_join import formatted_join_narrow
>>> formatted_join_narrow(['Only'])
'Only'
>>> formatted_join_narrow(['A', 'B', 'C'])
'A B C'
>>> formatted_join_narrow(['Line1', '-', 'Line2'])
'Line1 - Line2'
* Supported languages for formatted_join_[conjunction|disjunction]:
| language | and | or | separator | has penultimate separator |
|---|---|---|---|---|
| en | and | or | ', ' |
yes |
| de | und | oder | ', ' |
no |
Development
- Install Dependencies:
uv sync && uv pip install -r pyproject.toml --extra dev
- Run formater:
uv run ruff check --select I --fix && uv run ruff format
- Run type checking:
uv run mypy .
- Run unit tests:
uv run formatted_join_test.py
Metadata
Release files for formatted-join 1.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| formatted_join-1.1.2.tar.gz | 15.3 kB | Without provenance | Details for formatted_join-1.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| formatted_join-1.1.2-py3-none-any.whl | Python 3 | none | any | Details for formatted_join-1.1.2-py3-none-any.whl |
Total release size: 20.5 kB
Release files / formatted_join-1.1.2.tar.gz
| Download URL | formatted_join-1.1.2.tar.gz |
|---|---|
| Size | 15.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d191d4635976f474e94a8cb041c7d78f79edc5ad7146b56112795aee036c4c1e
|
|
BLAKE2b-256 checksum How to use checksums |
e864c55d2c2c0a606370fcd6e6059fa9645f3dee2fbefe149be4bfda72babee1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.5.2
|
Release files / formatted_join-1.1.2-py3-none-any.whl
| Download URL | formatted_join-1.1.2-py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2ef38c3d71ca364be5db9024c9576f69fe69cb01975b21608e8f3f5b8b618a7b
|
|
BLAKE2b-256 checksum How to use checksums |
066e652475af754d4f93418df310ad19212097e614d61ba0bdc054817a3ee21d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.5.2
|
Security for formatted-join 1.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.