<div>Yeah good idea with names because php ltrim does the same as lstrip in python.</div><div>Normally I'd expect strip to behave as I proposed, not like input a string as mask of characters, which is more rare use case and confusing in some scenarios.</div><div class="gmail_quote_attribution">On мар т 24 2019, at 11:34 утра, Anders Hovmöller <boxed@killingar.net> wrote:</div><blockquote><div><div>I don't see what trim() is good for but I know I've written ltrim() hundreds of times easy. </div><div><br></div><div>I propose naming them strip_prefix() and strip_suffix() and just skip the one that does both sides since it makes no sense to me. </div><div><br></div><div>Trim is generally a bad name because what is called strip() in python is called trim() in other languages. This would be needlessly confusing. </div><div><br><div>On 24 Mar 2019, at 09:42, Alex Grigoryev <<a href="https://link.getmailspring.com/link/5181B0DB-3B10-4202-90D6-1365AEF19654@getmailspring.com/0?redirect=mailto%3Aevrial%40gmail.com&recipient=cHl0aG9uLWlkZWFzQHB5dGhvbi5vcmc%3D" title="mailto:evrial@gmail.com">evrial@gmail.com</a>> wrote:</div><br></div><blockquote><div><div>Following the discussion <a href="https://link.getmailspring.com/link/5181B0DB-3B10-4202-90D6-1365AEF19654@getmailspring.com/1?redirect=https%3A%2F%2Flink.getmailspring.com%2Flink%2F7D84D131-65B6-4EF7-9C43-51957F9DFAA9%40getmailspring.com%2F0%3Fredirect%3Dhttps%253A%252F%252Fbugs.python.org%252Fissue36410%26recipient%3DcHl0aG9uLWlkZWFzQHB5dGhvbi5vcmc%253D&recipient=cHl0aG9uLWlkZWFzQHB5dGhvbi5vcmc%3D" title="https://link.getmailspring.com/link/7D84D131-65B6-4EF7-9C43-51957F9DFAA9@getmailspring.com/0?redirect=https%3A%2F%2Fbugs.python.org%2Fissue36410&recipient=cHl0aG9uLWlkZWFzQHB5dGhvbi5vcmc%3D">here</a> I propose to add 3 new string methods: str.trim, str.ltrim, str.rtrim</div><div>Another option would be to change API for str.split method to work correctly with sequences.</div><br><code><pre style="background-color:rgba(0,0,0,0.05);padding:0.2em 1em"><div><code>In [1]: def ltrim(s, seq):<br></code></div><div><code>   ...:     return s[len(seq):] if s.startswith(seq) else s<br></code></div><div><code>   ...:<br></code></div><br><div><code>In [2]: def rtrim(s, seq):<br></code></div><div><code>   ...:     return s[:-len(seq)] if s.endswith(seq) else s<br></code></div><div><code>   ...:<br></code></div><br><div><code>In [3]: def trim(s, seq):<br></code></div><div><code>   ...:     return ltrim(rtrim(s, seq), seq)<br></code></div><div><code>   ...:<br></code></div><br><div><code>In [4]: s = '</code><code><a href="https://link.getmailspring.com/link/5181B0DB-3B10-4202-90D6-1365AEF19654@getmailspring.com/2?redirect=mailto%3Amaria%40gmail.com&recipient=cHl0aG9uLWlkZWFzQHB5dGhvbi5vcmc%3D" title="mailto:maria@gmail.com">mailto:maria@gmail.com</a></code><code>'<br></code></div><br><div><code>In [5]: ltrim(s, 'mailto:')<br></code></div><div><code>Out[5]: '</code><code><a href="https://link.getmailspring.com/link/5181B0DB-3B10-4202-90D6-1365AEF19654@getmailspring.com/3?redirect=mailto%3Amaria%40gmail.com&recipient=cHl0aG9uLWlkZWFzQHB5dGhvbi5vcmc%3D" title="mailto:maria@gmail.com">maria@gmail.com</a></code><code>'<br></code></div><br><div><code>In [6]: rtrim(s, 'com')<br></code></div><div><code>Out[6]: 'mailto:maria@gmail.'<br></code></div><br><div><code>In [7]: trim(s, 'm')<br></code></div><div><code>Out[7]: 'ailto:</code><code><a href="https://link.getmailspring.com/link/5181B0DB-3B10-4202-90D6-1365AEF19654@getmailspring.com/4?redirect=mailto%3Amaria%40gmail.co&recipient=cHl0aG9uLWlkZWFzQHB5dGhvbi5vcmc%3D" title="mailto:maria@gmail.co">maria@gmail.co</a></code><code>'</code></div></pre></code><br><div><img class="mailspring-open" alt="Sent from Mailspring" width="0" height="0" style="border:0; width:0; height:0;" src="https://link.getmailspring.com/open/7D84D131-65B6-4EF7-9C43-51957F9DFAA9@getmailspring.com?recipient=cHl0aG9uLWlkZWFzQHB5dGhvbi5vcmc%3D"></div></div></blockquote><blockquote><div><div>_______________________________________________</div><div>Python-ideas mailing list</div><div><a href="https://link.getmailspring.com/link/5181B0DB-3B10-4202-90D6-1365AEF19654@getmailspring.com/5?redirect=mailto%3APython-ideas%40python.org&recipient=cHl0aG9uLWlkZWFzQHB5dGhvbi5vcmc%3D" title="mailto:Python-ideas@python.org">Python-ideas@python.org</a></div><div><a href="https://link.getmailspring.com/link/5181B0DB-3B10-4202-90D6-1365AEF19654@getmailspring.com/6?redirect=https%3A%2F%2Fmail.python.org%2Fmailman%2Flistinfo%2Fpython-ideas&recipient=cHl0aG9uLWlkZWFzQHB5dGhvbi5vcmc%3D" title="https://mail.python.org/mailman/listinfo/python-ideas">https://mail.python.org/mailman/listinfo/python-ideas</a></div><div>Code of Conduct: <a href="https://link.getmailspring.com/link/5181B0DB-3B10-4202-90D6-1365AEF19654@getmailspring.com/7?redirect=http%3A%2F%2Fpython.org%2Fpsf%2Fcodeofconduct%2F&recipient=cHl0aG9uLWlkZWFzQHB5dGhvbi5vcmc%3D" title="http://python.org/psf/codeofconduct/">http://python.org/psf/codeofconduct/</a></div></div></blockquote></div></blockquote><img class="mailspring-open" alt="Sent from Mailspring" width="0" height="0" style="border:0; width:0; height:0;" src="https://link.getmailspring.com/open/5181B0DB-3B10-4202-90D6-1365AEF19654@getmailspring.com?recipient=cHl0aG9uLWlkZWFzQHB5dGhvbi5vcmc%3D">