generator slides review
andrea crotti
andrea.crotti.0 at gmail.com
Sun Feb 2 11:52:26 CET 2014
Sorry left too early, the slides are updated with the fixes suggested,
thanks everyone.
https://dl.dropboxusercontent.com/u/3183120/talks/generators/index.html#1
For me the biggest problem is still:
- to find some more interesting example that is easy enough to explain
- to find a better order in which explain things, to tell a clear story in a way
2014-02-02 andrea crotti <andrea.crotti.0 at gmail.com>:
> The slides are updated now
>
> 2014-02-02 andrea crotti <andrea.crotti.0 at gmail.com>:
>> 2014-02-01 Miki Tebeka <miki.tebeka at gmail.com>:
>>>
>>> My 2 cents:
>>>
>>> slide 4:
>>> [i*2 for i in range(10)]
>>>
>>
>> Well this is not correct in theory because the end should be the max
>> number, not the number of elements.
>> So it should be
>> [i*2 for i in range(10/2)] which might be fine but it's not really
>> more clear imho..
>>
>>> slide 9:
>>> while True:
>>> try:
>>> it = next(g)
>>> body(it)
>>> except StopIteration:
>>> break
>>>
>>
>> Changed it thanks
>>
>>> slide 21:
>>> from itertools import count, ifilterfalse
>>>
>>> def divided_by(p):
>>> return lambda n: n % p == 0
>>>
>>> def primes():
>>> nums = count(2)
>>> while True:
>>> p = next(nums)
>>> yield p
>>> nums = ifilterfalse(divided_by(p), nums)
>>>
>>
>> Thank you that's nicer, but ifiilterfalse is not in Python 3 (could
>> use filter of course).
More information about the Python-list
mailing list