Hi Steven, On Sun, May 24, 2020, 8:14 AM Steven D'Aprano
sorted(paths, key=len∘str, reverse=True) *semi-wink*
Do you have an evil twin with whom you share email. Yesterday you were arguing against functional programming style on the grounds that filtering based on a predicate was too obscure represented as 'filter(pred, ...))' Today you want full function composition. Fwiw, I like function composition. This example makes a good case for it. Too bad that symbol isn't on most keyboards. I don't think 'compose(len, str)' looks so terrible, but it's longer.
So I implemented `PurePath.__len__` as `str(len(path))`.
Serhiy and Remi objected, because it might not be obvious that the length of the path would be the length of string.
It isn't obvious to me that the length of a path is the length of the string representation of that path.
I thought that the length of the path would be the number of path components:
/tmp/file # length 2
I wouldn't have predicted that was the length of the string representation of the path.
-- Steven _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/RHOPEZ... Code of Conduct: http://python.org/psf/codeofconduct/