Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #65259

Re: generator slides review

References <mailman.6278.1391263956.18130.python-list@python.org> <8118b17c-3352-4832-8567-089bd14c21ce@googlegroups.com> <CAF_E5JYd1boDw82a+ScAg9WR5z-Zwj_Qc3OWDfNtKXeVV+vRCw@mail.gmail.com> <CAF_E5JaMiFtuZBj6BgC0xPr1QJbdnP5Y7YHHfa-7Toy1A_1_+Q@mail.gmail.com>
Date 2014-02-02 10:52 +0000
Subject Re: generator slides review
From andrea crotti <andrea.crotti.0@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.6304.1391338354.18130.python-list@python.org> (permalink)

Show all headers | View raw


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@gmail.com>:
> The slides are updated now
>
> 2014-02-02 andrea crotti <andrea.crotti.0@gmail.com>:
>> 2014-02-01 Miki Tebeka <miki.tebeka@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).

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

generator slides review andrea crotti <andrea.crotti.0@gmail.com> - 2014-02-01 14:12 +0000
  Re: generator slides review Miki Tebeka <miki.tebeka@gmail.com> - 2014-02-01 08:50 -0800
    Re: generator slides review andrea crotti <andrea.crotti.0@gmail.com> - 2014-02-02 10:48 +0000
      Re: generator slides review Miki Tebeka <miki.tebeka@gmail.com> - 2014-02-02 06:59 -0800
        Re: generator slides review andrea crotti <andrea.crotti.0@gmail.com> - 2014-02-02 22:55 +0000
    Re: generator slides review andrea crotti <andrea.crotti.0@gmail.com> - 2014-02-02 10:50 +0000
    Re: generator slides review andrea crotti <andrea.crotti.0@gmail.com> - 2014-02-02 10:52 +0000
    Re: generator slides review Peter Otten <__peter__@web.de> - 2014-02-02 13:47 +0100

csiph-web