We're sorry but this page doesn't work properly without JavaScript enabled. Please enable it to continue.
Feedback

Kung Fu at Dawn with Itertools

Formal Metadata

Title
Kung Fu at Dawn with Itertools
Title of Series
Part Number
18
Number of Parts
169
Author
License
CC Attribution - NonCommercial - ShareAlike 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this
Identifiers
Publisher
Release Date
Language

Content Metadata

Subject Area
Genre
Abstract
Víctor Terrón - Kung Fu at Dawn with Itertools The itertools module is one of the cornerstones of advanced programming in Python. This talk offers practical advice about iterator algebra that can be put into practice immediately. Discovering the itertools module means taking the veil from our eyes, and once we use functions such as repeat, takewhile, dropwhile or product, there is no return — it is impossible to come back to the world of the mere mortals, where solutions are more complex and need more memory. ----- The itertools module is one of the cornerstones of advanced programming in Python. Part of the standard library, it provides an iterator algebra that allows us to elegantly chain abstractions, enabling solutions that are both simpler and more memory efficient. The goal of this talk is to offer practical advice and clear lessons that can be immediately put into practice. Illustrating it with numerous examples, attendees will leave having assimilated at least several concepts that will improve their code undeniably and irremediably. Emphasis will be on showing specific cases where a traditional solution can be overhauled over and over with functions from the itertools module. Let’s say, for example, that we want to alternate indefinitely between two values: -1 and 1. The novice would use a variable, updating its value at each step, and the average user would maybe opt for an endless generator. Both are worthy and honorable solutions, but they pale before the mastery of the martial artist who only needs itertools.cycle. Because that is the nature of the itertools module: once the veil falls from our eyes and we come across functions such as repeat, takewhile, dropwhile or product, there is no return. In this talk we will learn to identify when they can be used, accomplishing with a single line of code what for the mere mortals takes much more effort.