From 423b9c82f3d52dad892b10d21abe607930c5790f Mon Sep 17 00:00:00 2001 From: Bill Mitchell Date: Sat, 20 Jun 2020 17:36:15 -0400 Subject: [PATCH 1/2] Fixed some very minor typographical errors --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 21eff63..f903bcd 100644 --- a/README.md +++ b/README.md @@ -42,10 +42,10 @@ Python 3. - 2. Move complex expressions into helper functions, especially if you need to use the same logic repeatedly. - 3. The if/else expression provides a more readable alternative to using - Boolean operators like or and adn in expressions. + Boolean operators like or and and in expressions. -### [Item 5: Know hot to slice sequences](item_05_slice_sequence.py) +### [Item 5: Know how to slice sequences](item_05_slice_sequence.py) - 1. Avoid being verbose: Don't supply 0 for the start index or the length of the sequence for the end index. - 2. Slicing is forgiving of start or end indexes that are out of bounds, @@ -61,7 +61,7 @@ Python 3. indexes. Avoid negative stride values if possible. - 3. Avoid using start, end and stride together in a single slice. If you need all three parameters, consider doing two assignments (one to slice, - another to stride) or using islice form itertools built-in module. + another to stride) or using islice from itertools built-in module. ### [Item 7: Use list comprehensions instead of map and filter](item_07_list_not_map_filter.py) @@ -454,7 +454,7 @@ Python 3. - 2. Don't re-implement this functionality yourself. It's hard to get right. -### [Item 47: Use decimal when precision ia paramount](item_47_use_decimal.py) +### [Item 47: Use decimal when precision is paramount](item_47_use_decimal.py) - 1. Python has built-in types and classes in modules that can represent practically every type of numerical value. - 2. The Decimal class is ideal for situations that require high precision and @@ -493,7 +493,7 @@ Python 3. that contains other source files. These files become that child modules of the directory's package. Package directories may also contain other packages. -- 3. You can provide an explict API for a module by listing its publicly +- 3. You can provide an explicit API for a module by listing its publicly visible name in its __all__ special attribute. - 4. You can hide a package's internal implementation by only importing public names in the package's __init__.py file or by naming internal-only @@ -553,7 +553,7 @@ Python 3. - 2. Calling repr on built-in Python types will produce the printable string version of a value. These repr strings could be passed to the eval built-in function to get back the original value. -- 3. %s in format strings will produce human-readable strings like str.%r will +- 3. %s in format strings will produce human-readable strings like str. %r will produce printable strings like repr. - 4. You can define the __repr__ method to customize the printable representation of a class and provide more detailed debugging From f6bc1ee64b97a4fb48ad53cafcd45f3e49cc007d Mon Sep 17 00:00:00 2001 From: Bill Mitchell Date: Sat, 20 Jun 2020 17:43:35 -0400 Subject: [PATCH 2/2] More minor typographical corrections --- item_01_version_of_python.py | 4 ++-- item_02_PEP8Style.py | 2 +- item_03_Difference_bytes_str_unicode.py | 4 ++-- item_05_slice_sequence.py | 2 +- item_06_avoid_using.py | 4 ++-- item_07_list_not_map_filter.py | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/item_01_version_of_python.py b/item_01_version_of_python.py index 5ef5ad2..4562456 100644 --- a/item_01_version_of_python.py +++ b/item_01_version_of_python.py @@ -10,7 +10,7 @@ # readability (type import this). # Programmers familiar with other language may try to write Python as if it's -# C++, Java, or whatever know best. New programmers may still be getting +# C++, Java, or whatever they know best. New programmers may still be getting # comfortable with the vast range of concepts expressible in Python. It's # important for everyone to know the best--the Pythonic--way to do the most # common things in Python. These patterns will affect every program you write. @@ -37,7 +37,7 @@ # Things to Remember -# 1. There are two major version of Python still in active use: Python 2 and +# 1. There are two major versions of Python still in active use: Python 2 and # Python 3. # 2. There are multiple popular runtimes for Python: CPython, Jython, # IronPython, PyPy, etc. diff --git a/item_02_PEP8Style.py b/item_02_PEP8Style.py index 94a1bf9..d993174 100644 --- a/item_02_PEP8Style.py +++ b/item_02_PEP8Style.py @@ -20,7 +20,7 @@ # Naming: PEP 8 suggests unique styles of naming for different part in the # language. -# 1. Functions, variables, and attributs should be in lovercase_underscore +# 1. Functions, variables, and attributes should be in lowercase_underscore # format. # 2. Protected instance attributes should be in _leading_underscore format. # 3. Private instance attributes should be in __double_leading_underscore diff --git a/item_03_Difference_bytes_str_unicode.py b/item_03_Difference_bytes_str_unicode.py index 9459448..bf6e3b9 100644 --- a/item_03_Difference_bytes_str_unicode.py +++ b/item_03_Difference_bytes_str_unicode.py @@ -19,10 +19,10 @@ # When you're writing Python programs, it's important to do encoding and # decoding of Unicode at the furthest boundary of your interfaces. The core of # your program should use Unicode character types (str in Python 3, unicode in -# Python 2) and should not assume any thing about character encodings. This +# Python 2) and should not assume anything about character encodings. This # approach allows you to be very accepting of alternative text encodings # (such as Latin-1, Shift JIS, and Big5) while being strict about your output -# text encoding (idealy, UTF-8). +# text encoding (ideally, UTF-8). # The split between character types leads to two common situations in Python # code: diff --git a/item_05_slice_sequence.py b/item_05_slice_sequence.py index 902b097..9439a88 100644 --- a/item_05_slice_sequence.py +++ b/item_05_slice_sequence.py @@ -5,7 +5,7 @@ # access a subset of a sequence's items with minimal effort. The simplest uses # for slicing are the built-in types list, str, and bytes. Slicing can be # extended to any Python class that implements the __getitem__ and __setitem__ -# special methods (see Item 28: Inherit form collections.abc for custom +# special methods (see Item 28: Inherit from collections.abc for custom # container types). # The basic form of the slicing syntax is somelist[start:end], where start is diff --git a/item_06_avoid_using.py b/item_06_avoid_using.py index 65b7391..508a1db 100644 --- a/item_06_avoid_using.py +++ b/item_06_avoid_using.py @@ -17,7 +17,7 @@ # ['orange', 'green', 'purple'] -# The problem is that the stride syntax ofter cause unexpected behavior that +# The problem is that the stride syntax often cause unexpected behavior that # can introduce bugs. For example, a common Python trick for reversing a byte # string is to slice the string with a stride of -1. @@ -103,4 +103,4 @@ # indexes. Avoid negative stride values if possible. # 3. Avoid using start, end and stride together in a single slice. If you need # all three parameters, consider doing two assignments (one to slice, -# another to stride) or using islice form itertools built-in module. +# another to stride) or using islice from itertools built-in module. diff --git a/item_07_list_not_map_filter.py b/item_07_list_not_map_filter.py index 456bd21..2df8715 100644 --- a/item_07_list_not_map_filter.py +++ b/item_07_list_not_map_filter.py @@ -27,7 +27,7 @@ # [1, 4, 9, 16, 25, 36, 49, 64, 81, 100] -# Unlike may, list comprehensions let you easily filter items from the input +# Unlike map, list comprehensions let you easily filter items from the input # list, removing corresponding outputs from the result. For example, say you # only want to compute the squares of the numbers that are divisible by 2. # Here, I do this by adding a conditional expression to the list