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/150727.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 expressionEthan Furman ethan at stoneleaf.us
Wed Nov 22 16:32:38 EST 2017
On 11/22/2017 01:25 PM, Ivan Levkivskyi wrote:
> 22 Лис 2017 22:19 "Ethan Furman" пише:

>> Whether it's inside or outside a function should be irrelevant -- a comprehension / generator expression should have
>> no influence on the type of the resulting function (and at least synchronous comprehensions / generator expressions
>> should be able to live outside of a function).
>>
>>     def fun_gen():
>>           return list((yield i) for i in range(3))
>>
>>     The return says it's returning a list, so that's what it should be returning
>
> def f():
>      yield 1
>      return list()
>
> Here return also says it should return a list, so this is not an argument.

Right, the argument is that calling the `list` constructor should return a list -- not a database proxy, not a web page, 
and not a generator.

--
~Ethan~
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