
March 10, 2015
5:57 p.m.
On 15-03-10, Facundo Batista wrote:
That said, I bet this is the most common string-munging operations that *isn't* available as a single function in the stdlib. I know my bash code is full of ${filename%.suffix} and such, and the fact that in python I have to either import re or resort to some combination of (starts|ends)with, r?partition, slicing and an if-clause makes that sort of code much more verbose and harder to read. Pathlib's Path.with_suffix helps in some but not all of these cases. Maybe the stdlib should have a simple way to do this? It could even be added as a kwarg (exact=False) to str.[lr]strip to minimize the effect on the API; alternatively it could be str.strip(prefix|suffix). ijs
3638
Age (days ago)
3638
Last active (days ago)
1 comments
2 participants
participants (2)
-
Ethan Furman
-
Isaac Schwabacher