From 600e135d0067ff3f2f03ccb43c30be37d3d8b064 Mon Sep 17 00:00:00 2001 From: kracekumar Date: Thu, 13 Mar 2014 00:15:28 +0530 Subject: [PATCH 1/3] Added missing space in yield --- src/4/creating_data_processing_pipelines/example.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/4/creating_data_processing_pipelines/example.py b/src/4/creating_data_processing_pipelines/example.py index a7ff39a..9a2de51 100644 --- a/src/4/creating_data_processing_pipelines/example.py +++ b/src/4/creating_data_processing_pipelines/example.py @@ -10,7 +10,7 @@ def gen_find(filepat, top): ''' for path, dirlist, filelist in os.walk(top): for name in fnmatch.filter(filelist, filepat): - yield os.path.join(path,name) + yield os.path.join(path, name) def gen_opener(filenames): ''' From e885d712ff92c44e39dff7519c1608e12da4ee78 Mon Sep 17 00:00:00 2001 From: Ali Aliev Date: Mon, 18 Jan 2016 03:28:51 +0400 Subject: [PATCH 2/3] Missed is not None in chapter 8.14 (implementing custom containers) --- src/8/implementing_custom_containers/example1.py | 2 +- src/8/implementing_custom_containers/example2.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/8/implementing_custom_containers/example1.py b/src/8/implementing_custom_containers/example1.py index f8ab10f..a5d6112 100644 --- a/src/8/implementing_custom_containers/example1.py +++ b/src/8/implementing_custom_containers/example1.py @@ -5,7 +5,7 @@ class SortedItems(collections.Sequence): def __init__(self, initial=None): - self._items = sorted(initial) if initial is None else [] + self._items = sorted(initial) if initial is not None else [] # Required sequence methods def __getitem__(self, index): diff --git a/src/8/implementing_custom_containers/example2.py b/src/8/implementing_custom_containers/example2.py index f9cc6a5..cf2fd29 100644 --- a/src/8/implementing_custom_containers/example2.py +++ b/src/8/implementing_custom_containers/example2.py @@ -2,7 +2,7 @@ class Items(collections.MutableSequence): def __init__(self, initial=None): - self._items = list(initial) if initial is None else [] + self._items = list(initial) if initial is not None else [] # Required sequence methods def __getitem__(self, index): From 53a7ff2e332df0d2e8f9da425d4739f3997c4bdd Mon Sep 17 00:00:00 2001 From: Yukinari Tani Date: Mon, 6 Nov 2017 18:00:59 +0900 Subject: [PATCH 3/3] Add missing import functools in chapter 7 --- .../example1.py | 4 +++- .../example2.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/7/making_an_n-argument_callable_work_as_a_callable_with_fewer_arguments/example1.py b/src/7/making_an_n-argument_callable_work_as_a_callable_with_fewer_arguments/example1.py index 85f6517..85e1ae6 100644 --- a/src/7/making_an_n-argument_callable_work_as_a_callable_with_fewer_arguments/example1.py +++ b/src/7/making_an_n-argument_callable_work_as_a_callable_with_fewer_arguments/example1.py @@ -1,5 +1,7 @@ # Example of using partial() with sorting a list of (x,y) coordinates +import functools + points = [ (1, 2), (3, 4), (5, 6), (7, 7) ] import math @@ -9,5 +11,5 @@ def distance(p1, p2): return math.hypot(x2 - x1, y2 - y1) pt = (4,3) -points.sort(key=partial(distance, pt)) +points.sort(key=functools.partial(distance, pt)) print(points) diff --git a/src/7/making_an_n-argument_callable_work_as_a_callable_with_fewer_arguments/example2.py b/src/7/making_an_n-argument_callable_work_as_a_callable_with_fewer_arguments/example2.py index bfe4f0e..4071f2e 100644 --- a/src/7/making_an_n-argument_callable_work_as_a_callable_with_fewer_arguments/example2.py +++ b/src/7/making_an_n-argument_callable_work_as_a_callable_with_fewer_arguments/example2.py @@ -1,5 +1,7 @@ # Using partial to supply extra arguments to a callback function +import functools + def output_result(result, log=None): if log is not None: log.debug('Got: %r', result) @@ -17,6 +19,6 @@ def add(x, y): log = logging.getLogger('test') p = Pool() - p.apply_async(add, (3, 4), callback=partial(output_result, log=log)) + p.apply_async(add, (3, 4), callback=functools.partial(output_result, log=log)) p.close() p.join() pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy