This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author remi.lapeyre
Recipients SilentGhost, brandtbucher, cool-RR, pitrou, remi.lapeyre, serhiy.storchaka
Date 2020-05-24.10:33:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1590316408.31.0.016205018964.issue40752@roundup.psfhosted.org>
In-reply-to
Content
> 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.
History
Date User Action Args
2020-05-24 10:33:28remi.lapeyresetrecipients: + remi.lapeyre, pitrou, SilentGhost, cool-RR, serhiy.storchaka, brandtbucher
2020-05-24 10:33:28remi.lapeyresetmessageid: <1590316408.31.0.016205018964.issue40752@roundup.psfhosted.org>
2020-05-24 10:33:28remi.lapeyrelinkissue40752 messages
2020-05-24 10:33:28remi.lapeyrecreate