A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2017-November/150751.html below:

[Python-Dev] Tricky way of of creating a generator via a comprehension expression

[Python-Dev] Tricky way of of creating a generator via a comprehension expression [Python-Dev] Tricky way of of creating a generator via a comprehension expressionIvan Levkivskyi levkivskyi at gmail.com
Thu Nov 23 03:19:54 EST 2017
On 23 November 2017 at 09:15, Greg Ewing <greg.ewing at canterbury.ac.nz>
wrote:

> Ivan Levkivskyi wrote:
>
>> On 23 November 2017 at 05:44, Greg Ewing <greg.ewing at canterbury.ac.nz
>> <mailto:greg.ewing at canterbury.ac.nz>> wrote:
>>
>>        def g():
>>           return ((yield i) for i in range(10))
>>
>>
>> I think this code should be just equivalent to this code
>>
>>     def g():
>>         temp = [(yield i) for i in range(10)]
>>         return (v for v in temp)
>>
>
> But then you get a non-lazy iterable, which defeats the
> purpose of using a generator expression -- you might as
> well have used a comprehension to begin with.
>
>
This could be just a semantic equivalence (mental model), not how it should
be internally implemented.

--
Ivan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20171123/790c5c4f/attachment.html>
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4