[Python-ideas] Re: len(path) == len(str(path))

2020-05-25 Thread Christopher Barker
On Sun, May 24, 2020 at 4:59 AM Alex Hall wrote: > On Sun, May 24, 2020 at 1:42 PM Bernardo Sulzbach < > berna...@bernardosulzbach.com> wrote: > >> ... I would expect len(p) to be the "depth" of the path, which doesn't >> make a lot of sense if it is not an absolute path. >> > > I agree. I

[Python-ideas] Re: len(path) == len(str(path))

2020-05-25 Thread remi . lapeyre
Kyle Stanley wrote: > While I'm -1 on the original proposal, I think the idea of PurePath.__len__ > returning the number of components in the path may be worth some further > consideration. FYI PEP 428 says: In this proposal, the path classes do not derive from a builtin type. This

[Python-ideas] Re: len(path) == len(str(path))

2020-05-25 Thread M.-A. Lemburg
On 25.05.2020 03:34, Cameron Simpson wrote: > On 24May2020 13:46, M.-A. Lemburg wrote: >> It would be surprising to have an object which implements .__len__(), >> but otherwise doesn't allow any indexing, so -1 on such a change. > > set() ? I personally don't have a fundamental problem with

[Python-ideas] Re: len(path) == len(str(path))

2020-05-25 Thread Kyle Stanley
While I'm -1 on the original proposal, I think the idea of PurePath.__len__ returning the number of components in the path may be worth some further consideration. Also, I'm not convinced that having indexing is a necessary prerequisite to pursue it further. On Sun, May 24, 2020 at 8:14 AM Steven

[Python-ideas] Re: len(path) == len(str(path))

2020-05-24 Thread Steve Barnes
gt; Cc: python-ideas@python.org Subject: [Python-ideas] Re: len(path) == len(str(path)) Dan Sommers writes: > On the other hand, ∘ ruffles a lot of ASCII feathers (but I'm sure > Steven > knows that). On the gripping hand, "<>" looks more or less like a circle :-), and we co

[Python-ideas] Re: len(path) == len(str(path))

2020-05-24 Thread Cameron Simpson
On 24May2020 13:46, M.-A. Lemburg wrote: It would be surprising to have an object which implements .__len__(), but otherwise doesn't allow any indexing, so -1 on such a change. set() ? I personally don't have a fundamental problem with something having a size but no indexing. If Paths

[Python-ideas] Re: len(path) == len(str(path))

2020-05-24 Thread Stephen J. Turnbull
Dan Sommers writes: > On the other hand, ∘ ruffles a lot of ASCII feathers (but I'm sure > Steven knows that). On the gripping hand, "<>" looks more or less like a circle :-), and we could finally put barry_as_FLUFL __past__ us! ;-) Here's a wacky syntax idea: to get a partially applied

[Python-ideas] Re: len(path) == len(str(path))

2020-05-24 Thread Alex Hall
On Sun, May 24, 2020 at 3:38 PM Ram Rachum wrote: > What's wrong with using @? If I understand correctly, it's used for matrix > multiplication, which is far enough from function composition to avoid > confusion. And it's slightly similar visually to a circle. > The matrix multiplication PEP

[Python-ideas] Re: len(path) == len(str(path))

2020-05-24 Thread Ram Rachum
What's wrong with using @? If I understand correctly, it's used for matrix multiplication, which is far enough from function composition to avoid confusion. And it's slightly similar visually to a circle. On Sun, May 24, 2020 at 4:25 PM Dan Sommers < 2qdxy4rzwzuui...@potatochowder.com> wrote: >

[Python-ideas] Re: len(path) == len(str(path))

2020-05-24 Thread Dan Sommers
On Sunday, May 24, 2020, at 08:07 -0400, Steven D'Aprano wrote: > On Sun, May 24, 2020 at 02:27:00PM +0300, Ram Rachum wrote: > >> 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:

[Python-ideas] Re: len(path) == len(str(path))

2020-05-24 Thread Paul Sokolovsky
Hello, On Sun, 24 May 2020 08:23:29 -0400 David Mertz wrote: > 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

[Python-ideas] Re: len(path) == len(str(path))

2020-05-24 Thread David Mertz
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

[Python-ideas] Re: len(path) == len(str(path))

2020-05-24 Thread Alex Hall
On Sun, May 24, 2020 at 1:58 PM Ram Rachum wrote: > Well, looks like this proposal is dead in the water. Thanks for your > opinions everybody, I'll close the PR. > > Also, for Alex and Richard, `path.parts` would do the trick. > >> > > I know, that's why I

[Python-ideas] Re: len(path) == len(str(path))

2020-05-24 Thread Steven D'Aprano
On Sun, May 24, 2020 at 02:27:00PM +0300, Ram Rachum wrote: > 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) It would have been even

[Python-ideas] Re: len(path) == len(str(path))

2020-05-24 Thread David Mertz
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 wrote: > Hi everyone, > > I submitted a PR today, and Serhiy decided it needs a discussion on > python-ideas and agreement from core

[Python-ideas] Re: len(path) == len(str(path))

2020-05-24 Thread Ram Rachum
Well, looks like this proposal is dead in the water. Thanks for your opinions everybody, I'll close the PR. Also, for Alex and Richard, `path.parts` would do the trick. On Sun, May 24, 2020 at 2:55 PM Richard Damon wrote: > On 5/24/20 7:27 AM, Ram Rachum wrote: > > Hi everyone, > > > > I

[Python-ideas] Re: len(path) == len(str(path))

2020-05-24 Thread Paul Sokolovsky
Hello, On Sun, 24 May 2020 08:38:22 -0300 Bernardo Sulzbach wrote: > "So I implemented `PurePath.__len__` as `str(len(path))`." Sure you > meant len(str(path)), right? > > "Serhiy and Remi objected, because it might not be obvious that the > length of the path would be the length of string." I

[Python-ideas] Re: len(path) == len(str(path))

2020-05-24 Thread Alex Hall
On Sun, May 24, 2020 at 1:42 PM Bernardo Sulzbach < berna...@bernardosulzbach.com> wrote: > "Serhiy and Remi objected, because it might not be obvious that the length > of the path would be the length of string." I find this _really_ > unintuitive. If anything, I would expect len(p) to be the

[Python-ideas] Re: len(path) == len(str(path))

2020-05-24 Thread Richard Damon
On 5/24/20 7:27 AM, Ram Rachum 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: 

[Python-ideas] Re: len(path) == len(str(path))

2020-05-24 Thread M.-A. Lemburg
On 24.05.2020 13:27, Ram Rachum 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: 

[Python-ideas] Re: len(path) == len(str(path))

2020-05-24 Thread Bernardo Sulzbach
"So I implemented `PurePath.__len__` as `str(len(path))`." Sure you meant len(str(path)), right? "Serhiy and Remi objected, because it might not be obvious that the length of the path would be the length of string." I find this _really_ unintuitive. If anything, I would expect len(p) to be the