the OBSCENE string generation one-liner
Project description
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()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mapjoin-0.1.1.dev1.tar.gz
(1.7 kB
view details)
File details
Details for the file mapjoin-0.1.1.dev1.tar.gz
.
File metadata
- Download URL: mapjoin-0.1.1.dev1.tar.gz
- Upload date:
- Size: 1.7 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9ca6a213ea75cb0031d02d75bb4b54bdfcf33d496ceb2c7c1245cfa1f5e0463 |
|
MD5 | 5062063bfee3849beddca8d8b11713d4 |
|
BLAKE2b-256 | 73e2c069573fe03724107ad52a2b7e8df1146ead4d8a4068aa4e83226f0a3115 |