feature request: a better str.endswith
mis6 at pitt.edu
Wed Jul 23 04:11:33 CEST 2003
bokr at oz.net (Bengt Richter) wrote in message news:<bfi4ir$t21$0 at 184.108.40.206>...
> I think I'd prefer
> if any_true(filename.endswith, ('.jpg','.jpeg','.gif','.png')):
> I suspect it will more often make sense read aloud in the general
> if any_true(pred, seq):
> if the(pred, seq)
> I guess the full set of functions might be
> any_true, any_false, all_true, and all_false.
> or maybe someone can think of better short phrase?
> Bengt Richter
I think in the specific case I was talking about "the" was quite
readable; however I agree that in the general case "any_true" etc.
would be better.
I would not be opposed to add these convenience functions in
advantage is standardization (i.e. I don't have to invent my own name,
different from the name chosen by anybody else), the disadvantage is
more things to learn; however, with such descriptive names, it would
difficult to not grasp what those functions are doing, even without
looking at the documentation. Anyway, I am sure many will be opposed,
saying that such functions are so simple that they do not deserve to
in the library. This would be a sensible opinion, BTW.
More information about the Python-list