Functional Python Programming
Functions, Iterators, and Generators A display includes the enclosing literal syntax: [x**2 for x in range(10)]; this example is ...
Chapter 3 We've used one important for loop in addition to recursion. This allows us to easily handle numbers that have as many ...
Functions, Iterators, and Generators We defined an internal recursive function, factor_n(), to test factors, n, in the range 3 ≤ ...
Chapter 3 The other limitation of generator functions is that they can only be used once. For example, look at the following com ...
Functions, Iterators, and Generators We can tweak the original generator expression as follows: g_f_x = (g(f(x)) for x in range( ...
Chapter 3 Sadly, we can't trivially process this with the csv module. We have to do a little bit of parsing to extract the usefu ...
Functions, Iterators, and Generators The final conversions and data extractions are more easily done with higher-order functions ...
Chapter 3 The list(range(10)) function evaluated the generator expression. The [range(10)] list literal does not evaluate the ge ...
Functions, Iterators, and Generators We applied the tuple() function to a composite function based on the headsplit fixed() and ...
Chapter 3 To reduce memory use—and increase performance—we prefer to use generator expressions and functions as much as possible ...
Functions, Iterators, and Generators The first example, building a dictionary once, stems from an application with three operati ...
Chapter 3 Where the sequence variable is the iterable of the Color objects shown previously, the wrap() element of the design pa ...
Functions, Iterators, and Generators raise ValueError("{0!r} not found".format(key)) def iter(self): return iter(self._keys) def ...
Chapter 3 We might have a set of colors that we will use as a kind of chroma-key: we will use this color to create a mask that w ...
...
Working with Collections Python offers a number of functions that process whole collections. They can be applied to sequences (l ...
Working with Collections In the next chapter, we'll focus on using higher-order collection functions to do similar kinds of proc ...
Chapter 4 One common application of for loop iterable processing is the unwrap(process(wrap(iterable))) design pattern. A wrap() ...
Working with Collections We'll be looking for constructs such as the following code snippet: <Placemark><Point> < ...
Chapter 4 The result of this function is an iterable sequence of rows of data. Each row will be a tuple composed of three string ...
«
1
2
3
4
5
6
7
8
9
10
»
Free download pdf