On 11/10/19 15:48, Rhodri James wrote: > On 10/10/2019 12:40, Antoon Pardon wrote: >> About including piped iterators: >> >> http://code.activestate.com/recipes/580625-collection-pipeline-in-python/ >> >> On 10/10/19 13:00, Paul Moore wrote: >>> As another measure, look at various other libraries on PyPI and ask >>> yourself why *this* library needs to be in the stdlib more than those >>> others. The answer to that question would be a good start for an >>> argument to include the library. >> >> Well my answer would be that this library wouldn't add functionality >> but rather would allow IMO for a more readable coding style. >> >> If you split the work to be done over mulitple generators I find it >> easier to understand when I read something like: >> >> for item in some_file | gen1 | gen2 | gen3: >> ... >> >> than when I read something like: >> >> for item in gen3(gen2(gen1(somefile))): >> ... > > With my ever-so-reactionary hat on, I have to say I'm the other way > round. With "gen3(gen2(gen1(somefile)))" it's pretty obvious what's > going on -- nested function or generator calls, probably the latter > from the name. With "somefile|gen1|gen2|gen3" I need more context to > kick my expectations out of the more common meaning of "|" as "or". > > Yes, context demands that the "|" in your first example can't actually > be an "or". It still causes a moment of logical disconnect (currently > a long moment) that throws me out of understanding what your code is > doing overall into what this line means in particular. It's exactly > like coming across an unusual phrasing or iffy grammar in a piece of > writing; you get thrown out of the reading experience by having to > concentrate on the individual words.
But isn't this just a matter of experience? For example does it still causes a moment of logical disconnect when you see a '+' used for concatenation? For me the use of '|' is very similar to how it is used by unix shells. Would the use of an other operator ease this disconnect for you, maybe '>>', or wouldn't that make a difference? -- Antoon. -- https://mail.python.org/mailman/listinfo/python-list