[Python-ideas] + operator on generators

Wes Turner wes.turner at gmail.com
Tue Jun 27 19:34:11 EDT 2017


On Monday, June 26, 2017, Wes Turner <wes.turner at gmail.com> wrote:

>
>
> On Sunday, June 25, 2017, Wes Turner <wes.turner at gmail.com
> <javascript:_e(%7B%7D,'cvml','wes.turner at gmail.com');>> wrote:
>
>>
>>
>> On Sunday, June 25, 2017, Danilo J. S. Bellini <danilo.bellini at gmail.com>
>> wrote:
>>
>>> On Sun, Jun 25, 2017 at 3:06 PM, lucas via Python-ideas <
>>> python-ideas at python.org> wrote:
>>>
>>>> I often use generators, and itertools.chain on them.
>>>> What about providing something like the following:
>>>>
>>>>     a = (n for n in range(2))
>>>>     b = (n for n in range(2, 4))
>>>>     tuple(a + b)  # -> 0 1 2 3
>>>
>>>
>>> AudioLazy does that: https://github.com/danilobellini/audiolazy
>>>
>>
>> - http://toolz.readthedocs.io/en/latest/api.html#toolz.itertoolz.concat
>> and concatv
>>
>> - https://github.com/kachayev/fn.py#streams-and-infinite-seque
>> nces-declaration
>>  - Stream() << obj
>>
>
> << is __lshift__()
> <<= is __ilshift__()
>
> https://docs.python.org/2/library/operator.html
>
> Do Stream() and __lshift__() from fn.py not solve here?
>

In this syntax example, iter1 is mutated before iteration:

  iter_x = Stream(iter1) << iter2 << iter3
  iter1 <<= iter5 # IDK if fn.py yet has <<=
  list(iter1)
  list(iter_x)



>
>
>>
>>
>>>
>>>
>>> --
>>> Danilo J. S. Bellini
>>> ---------------
>>> "*It is not our business to set up prohibitions, but to arrive at
>>> conventions.*" (R. Carnap)
>>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170627/cbd1de4d/attachment.html>


More information about the Python-ideas mailing list