[Python-ideas] while conditional in list comprehension ??
Shane Green
shane at umbrellacode.com
Tue Jan 29 15:16:01 CET 2013
And, stupidly, I didn't put it in a generator…doh!
Shane Green
www.umbrellacode.com
408-692-4666 | shane at umbrellacode.com
On Jan 29, 2013, at 6:13 AM, Shane Green <shane at umbrellacode.com> wrote:
> How funny… I tried a variation of that because one of my original thoughts had been "[… if x else raise StopIteration()]" may have also made some sense. But I tried it based on the example from earlier, and hadn't even considered it was even closer….
>
>
>
>
>
> Shane Green
> www.umbrellacode.com
> 408-692-4666 | shane at umbrellacode.com
>
> On Jan 29, 2013, at 5:53 AM, Boris Borcic <bborcic at gmail.com> wrote:
>
>> |>>> def notyet(cond) :
>> if cond :
>> raise StopIteration
>> return True
>>
>> |>>> list(x for x in range(100) if notyet(x>10))
>> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>>
>>
>> _______________________________________________
>> Python-ideas mailing list
>> Python-ideas at python.org
>> http://mail.python.org/mailman/listinfo/python-ideas
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130129/82ba07f2/attachment.html>
More information about the Python-ideas
mailing list