On Mon, Apr 1, 2019 at 10:11 PM Dan Sommers <2QdxY4RzWzUUiLuE@potatochowder.com> wrote:
So I've seen someone (likely David Mertz?) ask for something
like filename.strip_suffix(('.png', '.jpg')).  What is the
context?  Is it strictly a filename processing program?  Do
you subsequently have to determine the suffix(es) at hand?

Yes, I've sometimes wanted something like "the basename of all the graphic files in that directory."  But here's another example that is from my actually current job:

I do machine-learning/data science for a living. As part of that, I generate a bunch of models that try to make predictions from the same dataset.  So I name those models like:

dataset1.KNN_distance_n10.gz
dataset1.KNN_distance_n10_poly2_scaled.xz
dataset2.KNN_manhattan_n6.zip
dataset2.KNN_distance_n10_poly2_scaled.xz
dataset1.KNN_minkowski_n5.gz
dataset1.LinSVC_Poly3_Scaled.gz
dataset2.LogReg.bz2
dataset2.LogReg_Poly.gz
dataset1.NuSVC_poly2_scaled.gz

I would like to answer the question "What types of models have I tried against the datasets?"  Obviously, I *can* answer this question.  But it would be pleasant to answer it like this:

styles = {model.lstrip(('dataset1', 'dataset2'))
               .rstrip(('gz', 'xz', 'zip', 'bz2))
          for model in models}

That's something very close to code I actually have in production now.

--
Keeping medicines from the bloodstreams of the sick; food
from the bellies of the hungry; books from the hands of the
uneducated; technology from the underdeveloped; and putting
advocates of freedom in prisons.  Intellectual property is
to the 21st century what the slave trade was to the 16th.