Steven D'Aprano :
> On Thu, 17 Mar 2016 02:20 am, Random832 wrote:
>> fpipe("abcd12345xyz", pfilter(str.isdigit), pmap(int), preduce(mul))
>
> Intriguing! Thank you for the suggestion.
Still want the pipeline syntax!
Marko
--
https://mail.python.org/mailman/listinfo/python-list
On Wed, Mar 16, 2016, at 11:20, Random832 wrote:
> How about:
>
> from functools import partial, reduce
> from operator import mul
> def rcall(arg, func): return func(arg)
> def fpipe(*args): return reduce(rcall, args)
It occurs to me that this suggests a further refinement: have all
functions (a
If I understand correctly, the binary right or overloading that's seen here
can be applied to any other computational objects.
I could also think of implementing it for input / output pipes overloading
the __ror__ method with .communicate() method of the Popen object [0].
-Sivan
[0]: https://doc
Sivan Greenberg :
> If I understand correctly, the binary right or overloading that's seen
> here can be applied to any other computational objects.
>
> I could also think of implementing it for input / output pipes
> overloading the __ror__ method with .communicate() method of the Popen
> object
On Wed, Mar 16, 2016 at 4:57 PM, Steven D'Aprano
wrote:
> There's a powerful technique used in shell-scripting languages like bash:
> pipes. The output of one function is piped in to become the input to the
> next function.
>
> According to Martin Fowler, this was also used extensively in Smallta
I use the pipe style a lot, but one of the annoyances is that many
functions in the python standardlib expect the first argument to be a
callable and the second an iterable. I tend to write a lot of
"p-functions" (functions which switch that order and make them
compatible to `pipe`).
from pelper
On Thu, Mar 17, 2016 at 4:04 AM, Marko Rauhamaa wrote:
> Question: Could the generators define __repr__ so you wouldn't need to
> terminate the pipeline with "List" in interactive use?
No no no no. You do NOT want __repr__ to fundamentally change the
state of the object (which it would in that ca
On Thu, 17 Mar 2016 04:04 am, Marko Rauhamaa wrote:
> Steven D'Aprano :
>
>> Here is a way to do functional-programming-like pipelines to collect
>> and transform values from an iterable:
>>
>>
https://code.activestate.com/recipes/580625-collection-pipeline-in-python/
>
> Nice. The other day we
On Wed, Mar 16, 2016, at 10:57, Steven D'Aprano wrote:
> For instance, we can take a string, extract all the digits, convert them
> to
> ints, and finally multiply the digits to give a final result:
>
> py> from operator import mul
> py> "abcd12345xyz" | Filter(str.isdigit) | Map(int) | Reduce(m
Steven D'Aprano :
> Here is a way to do functional-programming-like pipelines to collect
> and transform values from an iterable:
>
> https://code.activestate.com/recipes/580625-collection-pipeline-in-python/
Nice. The other day we talked about Python replacing bash. Pipelining is
a big step in t
++1 !
On Thu, Mar 17, 2016 at 6:31 PM, Random832 wrote:
>
>
> On Thu, Mar 17, 2016, at 10:36, Chris Angelico wrote:
> > This object has a generator/list duality, but if you observe it, it
> > collapses to a list. When used interactively, it'd be pretty much the
> > same as calling list() as the
Am 16.03.16 um 16:09 schrieb Joel Goldstick:
On Wed, Mar 16, 2016 at 10:57 AM, Steven D'Aprano
wrote:
py> from operator import mul
py> "abcd12345xyz" | Filter(str.isdigit) | Map(int) | Reduce(mul)
120
This is interesting, but the part I'm missing is the use of the Pipe
symbol '|' in python.
On Thu, 17 Mar 2016 02:20 am, Random832 wrote:
> How about:
>
> from functools import partial, reduce
> from operator import mul
> def rcall(arg, func): return func(arg)
> def fpipe(*args): return reduce(rcall, args)
> pfilter = partial(partial, filter)
> pmap = partial(partial, map)
> preduce =
On Wed, Mar 16, 2016, at 11:09, Joel Goldstick wrote:
> > This is interesting, but the part I'm missing is the use of the Pipe
> symbol '|' in python. Can you elaborate
His "Filter", "Map", and "Reduce" are classes which define __ror__
methods, obviously.
--
https://mail.python.org/mailman/listi
On Thu, Mar 17, 2016, at 10:36, Chris Angelico wrote:
> This object has a generator/list duality, but if you observe it, it
> collapses to a list. When used interactively, it'd be pretty much the
> same as calling list() as the last step, but in a script, they'd
> operate lazily.
>
> Quantum com
On Wed, Mar 16, 2016 at 5:39 PM, Steven D'Aprano
wrote:
> On Thu, 17 Mar 2016 02:22 am, Omar Abou Mrad wrote:
>
> > Would be nice if this was possible:
> >
> get_digits = Filter(str.isdigit) | Map(int)
> 'kjkjsdf399834' | get_digits
>
>
> Yes it would. I'll work on that.
>
>
> > Also, h
I wrote this little lib "pelper" [0] which has the elixir inspired
pipe [1]. I initially had an implementation that used operator
overloading but found that the "|" syntax was not really necessary. I
just use the function `pipe` [2]
Some examples from the repo:
``pipe`` allows you to turn somethi
On Thu, 17 Mar 2016 02:22 am, Omar Abou Mrad wrote:
> Would be nice if this was possible:
>
get_digits = Filter(str.isdigit) | Map(int)
'kjkjsdf399834' | get_digits
Yes it would. I'll work on that.
> Also, how about using '>>' instead of '|' for "Forward chaining"
Any particular re
On Wed, Mar 16, 2016 at 10:57 AM, Steven D'Aprano
wrote:
> There's a powerful technique used in shell-scripting languages like bash:
> pipes. The output of one function is piped in to become the input to the
> next function.
>
> According to Martin Fowler, this was also used extensively in Smallt
On 16.03.2016 16:09, Joel Goldstick wrote:
symbol '|' in python. Can you elaborate
bitwise or
--
https://mail.python.org/mailman/listinfo/python-list
On Fri, Mar 18, 2016 at 1:10 AM, Steven D'Aprano wrote:
> At the moment, the data being processed by the Map, Filter, etc. are
> ordinary lists or iterators. In order to give them a customer __repr__, I
> would have to change the Map and Filter __ror__ method to return some
> custom type which beh
21 matches
Mail list logo