Message369779
> Remi: Your use case is taken care of by `len(path.parts)`.
Yes, and your use case is taken care of by `len(str(path))` which works as well.
The reason in the PR is to simplify:
sorted(paths, key=lambda path: len(str(path)), reverse=True)
to
sorted(paths, key=len, reverse=True)
but why avoiding a few characters?
My remark is not that it __len__ should be len(path.parts) but that the semantics are unclear (I should have wrote "**if __len__ is defined** I would expect...")
Since the semantics are unclear I would except it not to be defined. Also, it's common to use a lambda or an helper function in sorted(), map(), filter(), etc. Most use case can't be covered using existing methods and shouldn't necessarely be. |
|
Date |
User |
Action |
Args |
2020-05-24 10:33:28 | remi.lapeyre | set | recipients:
+ remi.lapeyre, pitrou, SilentGhost, cool-RR, serhiy.storchaka, brandtbucher |
2020-05-24 10:33:28 | remi.lapeyre | set | messageid: <1590316408.31.0.016205018964.issue40752@roundup.psfhosted.org> |
2020-05-24 10:33:28 | remi.lapeyre | link | issue40752 messages |
2020-05-24 10:33:28 | remi.lapeyre | create | |
|