<div dir="auto">Oh and if you want to write ['a', 'b', 'c'].join('.')<div dir="auto"><br></div><div dir="auto">Check out pip install funcoperators and you can write :</div><div dir="auto"><br></div><div dir="auto"><span style="font-family:sans-serif">['a', 'b', 'c'] |join('.')</span><br></div><div dir="auto"><span style="font-family:sans-serif"><br></span></div><div dir="auto"><span style="font-family:sans-serif">Given you defined the function below :</span></div><div dir="auto"><span style="font-family:sans-serif"><br></span></div><div dir="auto"><span style="font-family:sans-serif">from funcoperators import postfix</span></div><div dir="auto"><span style="font-family:sans-serif">def join(sep):</span></div><div dir="auto"><span style="font-family:sans-serif">    return postfix(lambda it: sep.join(map(str, it))</span></div><div dir="auto"><span style="font-family:sans-serif"><br></span></div><div dir="auto"><span style="font-family:sans-serif">You can even choose the operator :</span></div><div dir="auto"><span style="font-family:sans-serif"><br></span></div><div dir="auto"><div dir="auto" style="font-family:sans-serif">['a', 'b', 'c'] -join('.')<br></div><span style="font-family:sans-serif">['a', 'b', 'c'] /join('.')</span><br></div><div dir="auto"><span style="font-family:sans-serif">['a', 'b', 'c'] @join('.')</span><span style="font-family:sans-serif"><br></span></div><div dir="auto"><span style="font-family:sans-serif">...</span></div><div dir="auto"><br></div><div dir="auto">Disclaimer : I'm the creator of funcoperators</div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, 29 Jan 2019, 02:43 Jamesie Pic <<a href="mailto:jpic@yourlabs.org">jpic@yourlabs.org</a> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Hello,</div><div><br></div><div>During the last 10 years, Python has made steady progress in convenience to assemble strings. However, it seems to me that joining is still, when possible, the cleanest way to code string assembly.</div><div><br></div><div>However, I'm still sometimes confused between the different syntaxes used by join methods:</div><div><br></div><div>0. os.path.join takes *args</div><div>1. str.join takes a list argument, this inconsistence make it easy to mistake with the os.path.join signature<br></div><div><br></div><div>Also, I still think that:</div><div><br></div><div>'_'.join(['cancel', name])</div><div><br></div><div>Would be more readable as such:</div><div><br></div><div>['cancel', name].join('_')<br></div><div><br></div><div>Not only this would fix both of my issues with the current status-quo, but this would also be completely backward compatible, and probably not very hard to implement: just add a join method to list.<br></div><div><br></div><div>Thanks in advance for your reply</div><div><br></div><div>Have a great day<br></div><div><br>-- <br><div dir="ltr" class="m_7784868534084840875gmail_signature"><div dir="ltr"><div>∞<br></div></div></div></div></div></div></div>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank" rel="noreferrer">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</blockquote></div>