Skip to main content

The purpose of the mapjoin function is to have an alternative to str.join that looks more like os.path.join (which takes *args).

Usage:

from mapjoin import mapjoin

mapjoin('foo', 2)           # return 'foo 2'
mapjoin('foo', 2, sep='_')  # return 'foo_2'

# you can also make mapjoin use your own callback with the key kwarg:
your_formatter = lambda key: str(key) if key else 'Nothin!'
mapjoin('foo', obj, 2, None, sep='\n', key=your_formatter)

But … why ?

Initially, because I make to many mistakes when I write an os.path.join call and then a str.join call in a row:

>>> os.path.join('a', 'b')
'a/b'

# and 2 seconds later i'm doing this:

>>> ' '.join('a', 'b')
TypeError: join() takes exactly one argument (2 given)

# and instead of "just fixit and move on", i decided have a take on join

But also because I can’t get no satisfaction with my code when it looks like:

readable = ' '.join(map(str, [
    'hello',
    f'__{name}__',
    something,
]))

# or:

def foo():
    readable = textwrap.dedent(f'''
    hello
    __{name}__
    ''').strip()

Participate to the story

Metadata

Release files for mapjoin 0.0.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 mapjoin 0.0.2
File Size Uploaded Provenance Actions
mapjoin-0.0.2.tar.gz 1.7 kB Without provenance Details for mapjoin-0.0.2.tar.gz

Release files / mapjoin-0.0.2.tar.gz

Download URL mapjoin-0.0.2.tar.gz
Size 1.7 kB
Tags Source
SHA-256 checksum
How to use checksums
773992a1e7614932baaa19bf5bef59e0d145a1f4bb29b55833a19df8c6cf79c0
BLAKE2b-256 checksum
How to use checksums
acd82214aa4d654d77ef921db9210eead8a6bb8ad532bfa62ff63226300512f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.6

Security for mapjoin 0.0.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.

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