[Python-ideas] Add list.join() please
Jamesie Pic
jpic at yourlabs.org
Wed Jan 30 06:13:32 EST 2019
Wow, thanks for your great reply Steven ! It really helps me get a
better understanding of what I'm trying to do and move forward in my
research !
Some values are not going to be nice as strings, so I think I'm more
going to try to make a convenience shortcut for str map join, for when
I want to generate a human readable string. Ie.: mapjoin(*args,
sep='\n', key=str). Then I could replace:
readable = '\n'.join(map(str, [
'hello',
f'__{name}__',
etc...
]))
OR
def foo():
readable = textwrap.dedent(f'''
hello
__{name}__
''').strip()
With:
readable = mapjoin(
'hello',
f'__{name}__'
sep='\n',
# map=format_record could be used
)
That removes the "fuzzy" feeling I get from my previous proposals.
So, after a while if people are using that mapjoin that we could have
on PyPi, we could perhaps consider it to improve str.join. Or, do you
think adding such features to str.join is still discussable ?
More information about the Python-ideas
mailing list