Like several other commenters, I would expect len(path) to be its depth, not the length of its string representation.
On Sun, May 24, 2020, 7:30 AM Ram Rachum <r...@rachum.com> wrote: > Hi everyone, > > I submitted a PR today, and Serhiy decided it needs a discussion on > python-ideas and agreement from core developers before it could go forward. > > BPO: https://bugs.python.org/issue40752 > PR: https://github.com/python/cpython/pull/20348 > > Today I wrote a script and did this: > > sorted(paths, key=lambda path: len(str(path)), reverse=True) > > But it would have been nicer if I could do this: > > sorted(paths, key=len, reverse=True) > > 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. > > What do you think? Can I get some +1s and -1s for this change? > > > Thanks, > Ram. > > > _______________________________________________ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@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/2CD4QYG3TDRCMNHRWZK3N2ZLHYLGESFK/ > Code of Conduct: http://python.org/psf/codeofconduct/ >
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@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/LWHVZZQTDJQBF57PJCSCJC3VAZKFE3GY/ Code of Conduct: http://python.org/psf/codeofconduct/