Other articles

  1. Don't waste your iterators!

    There's a pattern I see fairly often in code where someone uses a function that returns a sequence of some sort, filters it, and then wants to use the first result that matches the filter. It looks something like this:

    return [x for x in foo if len(x ...
    read more

    There are comments.

  2. Iterators and iterables clarified


    Need to fix code formatting

    So what exactly is a python iterator, and how is that different from an iterable?

    An iterable is an object that implements a method __iter__(), which, when called, returns an iterator. The __iter__() method can be called by the iter() function, and is also ...

    read more

    There are comments.

  3. Page 1 / 1