[Python-ideas] Integrate some itertools into the Python syntax

Michel Desmoulin desmoulinmichel at gmail.com
Fri Mar 25 18:16:05 EDT 2016


Le 25/03/2016 17:53, Nikolaus Rath a écrit :
> On Mar 25 2016, Michel Desmoulin <desmoulinmichel-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org> wrote:
>> It's also very convenient for generator expressions:
>>
>> # get random numbers between 0 and 100000, and square them
>> # remove all numbers you can't devide by 3
>> # then sample 100 of them
>>
>> numbers = (x * x for x in random.randint(100000) if x % 3 == 0)
>> for x in numbers[:100]:
>>     print(x)
> 
> If there has ever been an example that I hope to never, ever see in
> actual code than it's this one. If you have to make up stuff like that
> to justify a proposed feature, then that does not bode well.

The (x * x for x in random.randint(100000) if x % 3 == 0) is just here
to stand for "rich generators". The example is artificial, but every
advanced python code out there use generator.

The feature is on the for loop, which is simple and elegant.

What you're doing here is trolling, really.

> 
> 
> Best,
> -Nikolaus
> 


More information about the Python-ideas mailing list