diff --git a/.gitignore b/.gitignore index 2750f8ee..5a3d3501 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,7 @@ __pycache__/ *.pyc *_env/ -.venv/ +.venv*/ online_resources_site/site/ diff --git a/chapter_16/mapping_global_datasets/eq_explore_data.py b/chapter_16/mapping_global_datasets/eq_explore_data.py index 271bde6a..b39a6745 100644 --- a/chapter_16/mapping_global_datasets/eq_explore_data.py +++ b/chapter_16/mapping_global_datasets/eq_explore_data.py @@ -4,7 +4,7 @@ # Read data as a string and convert to a Python object. path = Path('eq_data/eq_data_1_day_m1.geojson') -contents = path.read_text() +contents = path.read_text(encoding='utf-8') all_eq_data = json.loads(contents) # Examine all earthquakes in the dataset. diff --git a/chapter_16/mapping_global_datasets/eq_world_map.py b/chapter_16/mapping_global_datasets/eq_world_map.py index 1902b652..d59236e9 100644 --- a/chapter_16/mapping_global_datasets/eq_world_map.py +++ b/chapter_16/mapping_global_datasets/eq_world_map.py @@ -6,7 +6,7 @@ # Read data as a string and convert to a Python object. path = Path('eq_data/eq_data_30_day_m1.geojson') -contents = path.read_text() +contents = path.read_text(encoding='utf-8') all_eq_data = json.loads(contents) # Examine all earthquakes in the dataset. diff --git a/chapter_16/mapping_global_datasets/partial_programs/eq_explore_data_0_first_version.py b/chapter_16/mapping_global_datasets/partial_programs/eq_explore_data_0_first_version.py index ce187d43..e5780a25 100644 --- a/chapter_16/mapping_global_datasets/partial_programs/eq_explore_data_0_first_version.py +++ b/chapter_16/mapping_global_datasets/partial_programs/eq_explore_data_0_first_version.py @@ -4,7 +4,7 @@ # Read data as a string and convert to a Python object. path = Path('eq_data/eq_data_1_day_m1.geojson') -contents = path.read_text() +contents = path.read_text(encoding='utf-8') all_eq_data = json.loads(contents) # Create a more readable version of the data file. diff --git a/chapter_16/mapping_global_datasets/partial_programs/eq_explore_data_1_list_all_earthquakes.py b/chapter_16/mapping_global_datasets/partial_programs/eq_explore_data_1_list_all_earthquakes.py index d5b33a85..af9a1725 100644 --- a/chapter_16/mapping_global_datasets/partial_programs/eq_explore_data_1_list_all_earthquakes.py +++ b/chapter_16/mapping_global_datasets/partial_programs/eq_explore_data_1_list_all_earthquakes.py @@ -4,7 +4,7 @@ # Read data as a string and convert to a Python object. path = Path('eq_data/eq_data_1_day_m1.geojson') -contents = path.read_text() +contents = path.read_text(encoding='utf-8') all_eq_data = json.loads(contents) # Examine all earthquakes in the dataset. diff --git a/chapter_16/mapping_global_datasets/partial_programs/eq_explore_data_2_extract_magnitudes.py b/chapter_16/mapping_global_datasets/partial_programs/eq_explore_data_2_extract_magnitudes.py index 342031e5..cbaa60d4 100644 --- a/chapter_16/mapping_global_datasets/partial_programs/eq_explore_data_2_extract_magnitudes.py +++ b/chapter_16/mapping_global_datasets/partial_programs/eq_explore_data_2_extract_magnitudes.py @@ -4,7 +4,7 @@ # Read data as a string and convert to a Python object. path = Path('eq_data/eq_data_1_day_m1.geojson') -contents = path.read_text() +contents = path.read_text(encoding='utf-8') all_eq_data = json.loads(contents) # Examine all earthquakes in the dataset. diff --git a/chapter_16/mapping_global_datasets/partial_programs/eq_explore_data_3_extract_location_data.py b/chapter_16/mapping_global_datasets/partial_programs/eq_explore_data_3_extract_location_data.py index 271bde6a..b39a6745 100644 --- a/chapter_16/mapping_global_datasets/partial_programs/eq_explore_data_3_extract_location_data.py +++ b/chapter_16/mapping_global_datasets/partial_programs/eq_explore_data_3_extract_location_data.py @@ -4,7 +4,7 @@ # Read data as a string and convert to a Python object. path = Path('eq_data/eq_data_1_day_m1.geojson') -contents = path.read_text() +contents = path.read_text(encoding='utf-8') all_eq_data = json.loads(contents) # Examine all earthquakes in the dataset. diff --git a/chapter_16/mapping_global_datasets/partial_programs/eq_world_map_0_first_version.py b/chapter_16/mapping_global_datasets/partial_programs/eq_world_map_0_first_version.py index fdd83591..07ba2e8a 100644 --- a/chapter_16/mapping_global_datasets/partial_programs/eq_world_map_0_first_version.py +++ b/chapter_16/mapping_global_datasets/partial_programs/eq_world_map_0_first_version.py @@ -6,7 +6,7 @@ # Read data as a string and convert to a Python object. path = Path('eq_data/eq_data_1_day_m1.geojson') -contents = path.read_text() +contents = path.read_text(encoding='utf-8') all_eq_data = json.loads(contents) # Examine all earthquakes in the dataset. diff --git a/chapter_16/mapping_global_datasets/partial_programs/eq_world_map_1_representing_magnitudes.py b/chapter_16/mapping_global_datasets/partial_programs/eq_world_map_1_representing_magnitudes.py index a6e0568b..5988d883 100644 --- a/chapter_16/mapping_global_datasets/partial_programs/eq_world_map_1_representing_magnitudes.py +++ b/chapter_16/mapping_global_datasets/partial_programs/eq_world_map_1_representing_magnitudes.py @@ -6,7 +6,7 @@ # Read data as a string and convert to a Python object. path = Path('eq_data/eq_data_30_day_m1.geojson') -contents = path.read_text() +contents = path.read_text(encoding='utf-8') all_eq_data = json.loads(contents) # Examine all earthquakes in the dataset. diff --git a/chapter_16/mapping_global_datasets/partial_programs/eq_world_map_2_custom_marker_colors.py b/chapter_16/mapping_global_datasets/partial_programs/eq_world_map_2_custom_marker_colors.py index ae1420ec..f5d75d8f 100644 --- a/chapter_16/mapping_global_datasets/partial_programs/eq_world_map_2_custom_marker_colors.py +++ b/chapter_16/mapping_global_datasets/partial_programs/eq_world_map_2_custom_marker_colors.py @@ -6,7 +6,7 @@ # Read data as a string and convert to a Python object. path = Path('eq_data/eq_data_30_day_m1.geojson') -contents = path.read_text() +contents = path.read_text(encoding='utf-8') all_eq_data = json.loads(contents) # Examine all earthquakes in the dataset. diff --git a/chapter_16/mapping_global_datasets/partial_programs/eq_world_map_3_adding_hover_text.py b/chapter_16/mapping_global_datasets/partial_programs/eq_world_map_3_adding_hover_text.py index 1902b652..d59236e9 100644 --- a/chapter_16/mapping_global_datasets/partial_programs/eq_world_map_3_adding_hover_text.py +++ b/chapter_16/mapping_global_datasets/partial_programs/eq_world_map_3_adding_hover_text.py @@ -6,7 +6,7 @@ # Read data as a string and convert to a Python object. path = Path('eq_data/eq_data_30_day_m1.geojson') -contents = path.read_text() +contents = path.read_text(encoding='utf-8') all_eq_data = json.loads(contents) # Examine all earthquakes in the dataset. diff --git a/chapter_17/hn_submissions.py b/chapter_17/hn_submissions.py index 7477226e..e6ae1950 100644 --- a/chapter_17/hn_submissions.py +++ b/chapter_17/hn_submissions.py @@ -12,7 +12,7 @@ submission_ids = r.json() submission_dicts = [] -for submission_id in submission_ids[:5]: +for submission_id in submission_ids[:30]: # Make a new API call for each submission. url = f"https://hacker-news.firebaseio.com/v0/item/{submission_id}.json" r = requests.get(url) diff --git a/chapter_17/python_repos.py b/chapter_17/python_repos.py index b480a811..e7bb11be 100644 --- a/chapter_17/python_repos.py +++ b/chapter_17/python_repos.py @@ -21,7 +21,6 @@ print("\nSelected information about each repository:") for repo_dict in repo_dicts: - print("\nSelected information about first repository:") print(f"Name: {repo_dict['name']}") print(f"Owner: {repo_dict['owner']['login']}") print(f"Stars: {repo_dict['stargazers_count']}") diff --git a/online_resources_site/docs/cheat_sheets.md b/online_resources_site/docs/cheat_sheets.md index cc4a05e8..1602b328 100644 --- a/online_resources_site/docs/cheat_sheets.md +++ b/online_resources_site/docs/cheat_sheets.md @@ -6,9 +6,11 @@ title: Cheat Sheets # Cheat Sheets +![Beginner's Python Cheat Sheets, first page](images/pcc_3e_cheat_sheet_image_corner.png){ align=right } + Cheat sheets can be really helpful when you’re trying a set of exercises related to a specific topic, or working on a project. Because you can only fit so much information on a single sheet of paper, most cheat sheets are a simple listing of syntax rules. This set of cheat sheets aims to remind you of syntax rules, but also remind you of important concepts as well. -You can click here and download [all of the sheets in a single document](https://github.com/ehmatthes/pcc_3e/releases/download/v1.0.0/beginners_python_cheat_sheet_pcc_all.pdf). To see a listing of individual sheets available for downloading, including a printer-friendly black and white version, click [here](). +You can download [all of the sheets in a single color document](https://github.com/ehmatthes/pcc_3e/releases/download/v1.0.0/beginners_python_cheat_sheet_pcc_all.pdf). You can also download a [zip file](https://github.com/ehmatthes/pcc_3e/releases/download/v1.0.0/beginners_python_cheat_sheet_all.zip) containing all color and printer-friendly black and white versions. The full set includes: @@ -25,37 +27,37 @@ These sheets are completely free to use and share. I originally wrote them as a ### Overview Sheet -- Beginner's Python Cheat Sheet +- [Beginner's Python Cheat Sheet](https://github.com/ehmatthes/pcc_3e/releases/download/v1.0.0/beginners_python_cheat_sheet_pcc.pdf) - Provides an overview of the basics of Python including variables, lists, dictionaries, functions, classes, and more. ### Python Basics -- Beginner's Python Cheat Sheet - Lists +- Beginner's Python Cheat Sheet - [Lists](https://github.com/ehmatthes/pcc_3e/releases/download/v1.0.0/beginners_python_cheat_sheet_pcc_lists.pdf) - Focuses on lists: how to build and modify a list, access elements from a list, and loop through the values in a list. Also covers numerical lists, list comprehensions, tuples, and more. -- Beginner's Python Cheat Sheet - Dictionaries +- Beginner's Python Cheat Sheet - [Dictionaries](https://github.com/ehmatthes/pcc_3e/releases/download/v1.0.0/beginners_python_cheat_sheet_pcc_dictionaries.pdf) - Focuses on dictionaries: how to build and modify a dictionary, access the information in a dictionary, and loop through dictionaries in a variety of ways. Includes sections on nesting lists and dictionaries, using dictionary comprehensions, and more. -- Beginner's Python Cheat Sheet - If Statements and While Loops +- Beginner's Python Cheat Sheet - [If Statements and While Loops](https://github.com/ehmatthes/pcc_3e/releases/download/v1.0.0/beginners_python_cheat_sheet_pcc_if_while.pdf) - Focuses on `if` statements and `while` loops: how to write conditional tests with strings and numerical data, how to write simple and complex if statements, and how to accept user input. Also covers a variety of approaches to using `while` loops. -- Beginner's Python Cheat Sheet - Functions +- Beginner's Python Cheat Sheet - [Functions](https://github.com/ehmatthes/pcc_3e/releases/download/v1.0.0/beginners_python_cheat_sheet_pcc_functions.pdf) - Focuses on functions: how to define a function and how to pass information to a function. Covers positional and keyword arguments, return values, passing lists, using modules, and more -- Beginner's Python Cheat Sheet - Classes +- Beginner's Python Cheat Sheet - [Classes](https://github.com/ehmatthes/pcc_3e/releases/download/v1.0.0/beginners_python_cheat_sheet_pcc_classes.pdf) - Focuses on classes: how to define and use a class. Covers attributes and methods, inheritance and importing, and more. -- Beginner's Python Cheat Sheet - Files and Exceptions +- Beginner's Python Cheat Sheet - [Files and Exceptions](https://github.com/ehmatthes/pcc_3e/releases/download/v1.0.0/beginners_python_cheat_sheet_pcc_files_exceptions.pdf) - Focuses on working with files, and using exceptions to handle errors that might arise as your programs run. Covers reading and writing to files, try-except-else blocks, and storing data using the `json` module. -- Beginner's Python Cheat Sheet - Testing Your Code +- Beginner's Python Cheat Sheet - [Testing Your Code](https://github.com/ehmatthes/pcc_3e/releases/download/v1.0.0/beginners_python_cheat_sheet_pcc_testing.pdf) - Focuses on unit tests and test cases. How to test a function, and how to test a class. ## Project-Focused Sheets -- Beginner's Python Cheat Sheet - Pygame +- Beginner's Python Cheat Sheet - [Pygame](https://github.com/ehmatthes/pcc_3e/releases/download/v1.0.0/beginners_python_cheat_sheet_pcc_pygame.pdf) - Focuses on creating games with Pygame. Creating a game window, rect objects, images, responding to keyboard and mouse input, groups, detecting collisions between game elements, and rendering text -- Beginner's Python Cheat Sheet - Matplotlib +- Beginner's Python Cheat Sheet - [Matplotlib](https://github.com/ehmatthes/pcc_3e/releases/download/v1.0.0/beginners_python_cheat_sheet_pcc_matplotlib.pdf) - Focuses on creating visualizations with Matplotlib. Making line graphs and scatter plots, customizing plots, making multiple plots, and working with time-based data. -- Beginner's Python Cheat Sheet - Plotly +- Beginner's Python Cheat Sheet - [Plotly](https://github.com/ehmatthes/pcc_3e/releases/download/v1.0.0/beginners_python_cheat_sheet_pcc_plotly.pdf) - Focuses on creating visualizations with Plotly. Making line graphs, scatter plots, and bar graphs, styling plots, making multiple plots, and working with geographical datasets. -- Beginner's Python Cheat Sheet - Django +- Beginner's Python Cheat Sheet - [Django](https://github.com/ehmatthes/pcc_3e/releases/download/v1.0.0/beginners_python_cheat_sheet_pcc_django.pdf) - Focuses on creating web apps with Django. Installing Django and starting a project, working with models, building a home page, using templates, using data, and making user accounts. -- Beginner's Python Cheat Sheet - Git +- Beginner's Python Cheat Sheet - [Git](https://github.com/ehmatthes/pcc_3e/releases/download/v1.0.0/beginners_python_cheat_sheet_pcc_git.pdf) - Focuses on using Git for version control. Installing and configuring Git, initializing a repository, branching, getting started with GitHub, and more. --- diff --git a/online_resources_site/docs/images/pcc_3e_cheat_sheet_image.png b/online_resources_site/docs/images/pcc_3e_cheat_sheet_image.png new file mode 100644 index 00000000..d4127b94 Binary files /dev/null and b/online_resources_site/docs/images/pcc_3e_cheat_sheet_image.png differ diff --git a/online_resources_site/docs/images/pcc_3e_cheat_sheet_image_250px.png b/online_resources_site/docs/images/pcc_3e_cheat_sheet_image_250px.png new file mode 100644 index 00000000..cc6cf180 Binary files /dev/null and b/online_resources_site/docs/images/pcc_3e_cheat_sheet_image_250px.png differ diff --git a/online_resources_site/docs/images/pcc_3e_cheat_sheet_image_corner.png b/online_resources_site/docs/images/pcc_3e_cheat_sheet_image_corner.png new file mode 100644 index 00000000..0c129ea9 Binary files /dev/null and b/online_resources_site/docs/images/pcc_3e_cheat_sheet_image_corner.png differ diff --git a/online_resources_site/docs/index.md b/online_resources_site/docs/index.md index 81e48ecd..1f922afe 100644 --- a/online_resources_site/docs/index.md +++ b/online_resources_site/docs/index.md @@ -13,7 +13,7 @@ The simplest way to download the source code files for the book is to click on t [Download .zip](https://github.com/ehmatthes/pcc_3e/archive/refs/heads/main.zip){ .md-button .md-button--primary } [View on GitHub](https://github.com/ehmatthes/pcc_3e/){ .md-button } -*The full set of resources for the third edition is still being developed. If you are an early reader of the third edition, some of the [second edition's resources](https://ehmatthes.github.io/pcc_2e/regular_index/) may still be useful, such as the [Cheat Sheets](https://ehmatthes.github.io/pcc_2e/cheat_sheets/cheat_sheets/) and articles such as [Finding Employment](https://ehmatthes.github.io/pcc_2e/finding_employment/).* +*Note: Some of the [second edition's resources](https://ehmatthes.github.io/pcc_2e/regular_index/) may still be useful, such as [Finding Employment](https://ehmatthes.github.io/pcc_2e/finding_employment/) and [Recommended Reading](https://ehmatthes.github.io/pcc_2e/recommended_reading/recommended_reading/).* --- @@ -22,7 +22,7 @@ If you have any questions about Python Crash Course, feel free to get in touch: Email: [ehmatthes@gmail.com](mailto:ehmatthes@gmail.com) -Twitter: [@ehmatthes](https://twitter.com/ehmatthes) +Bluesky: [@ehmatthes.bsky.social](https://bsky.app/profile/ehmatthes.bsky.social) Mastodon: [@ehmatthes@fosstodon.org](https://fosstodon.org/@ehmatthes) @@ -31,4 +31,4 @@ Mastodon: [@ehmatthes@fosstodon.org](https://fosstodon.org/@ehmatthes) [![Python Crash Course, 3rd Edition cover](images/pcc_3e_cover-170px.png)](https://nostarch.com/python-crash-course-3rd-edition) -Available from [No Starch Press](https://nostarch.com/python-crash-course-3rd-edition), [Amazon](https://www.amazon.com/Python-Crash-Course-Eric-Matthes-dp-1718502702/dp/1718502702/), and [Barnes & Noble](https://www.barnesandnoble.com/w/python-crash-course-3rd-edition-eric-matthes/1141287011). You can also find *Python Crash Course* in person at Barnes & Noble bookstores, and other fine booksellers worldwide. +Available from [No Starch Press](https://nostarch.com/python-crash-course-3rd-edition), [Amazon](https://www.amazon.com/Python-Crash-Course-Eric-Matthes-dp-1718502702/dp/1718502702/), and [Barnes & Noble](https://www.barnesandnoble.com/w/python-crash-course-3rd-edition-eric-matthes/1142968265). You can also find *Python Crash Course* in person at Barnes & Noble bookstores, and other fine booksellers worldwide. diff --git a/online_resources_site/docs/newsletter.md b/online_resources_site/docs/newsletter.md index 72c3c305..a1dcf3a7 100644 --- a/online_resources_site/docs/newsletter.md +++ b/online_resources_site/docs/newsletter.md @@ -6,24 +6,34 @@ title: Newsletter # Newsletter -I write a weekly newsletter about (almost) all things Python at [Mostly Python](https://mostlypython.substack.com). There are paid subscriptions available to support this ongoing work, but you can also sign up for a free subscription with access to all the same content. (Paid subscribers see some posts before free subscribers, but all posts end up available to everyone within 6 weeks.) +I write a weekly newsletter called [Mostly Python](https://www.mostlypython.com). There are paid subscriptions available to support this ongoing work, but you can also sign up for a free subscription with access to all the same content. (Paid subscribers see some posts before free subscribers, but all posts end up available to everyone within 6 weeks.) Most of what I write will be meaningful to anyone who has worked through a significant portion of *Python Crash Course*, and is interested in current takes on a variety of topics centered around Python. My goal is to help people transition out of the beginner mindset, and keep up with things that are happening in the Python world. +--- + If you're curious to read some posts, you might want to start with one of these: -- [Why I'm still using Python](https://mostlypython.substack.com/p/why-im-still-using-python) - - This explains why I'm still doing most of my programming work in Python, 16 years after I was first introduced to the language. +- [Python Lists: A closer look](https://www.mostlypython.com/python-lists-a-closer-look-7e0/) + + This series digs under the hood to see how lists work, and when to consider using a different kind of sequence in your projects. -- [Python Lists: A closer look](https://mostlypython.substack.com/p/python-lists-a-closer-look) +- [OOP in Python](https://www.mostlypython.com/oop-in-python/) - This is the first post in a series about lists, and how a focus on this simple data structure can help people develop a deeper understanding of Python as a whole. + This series takes a deep dive into looking at how object-oriented programming works, and why it's so important. -- [Improving medical students' lives with code](https://mostlypython.substack.com/p/improving-medical-students-lives) +- [Django from first principles series](https://www.mostlypython.com/django-from-first-principles-2/) + + This series builds a standard Django project by starting with a single .py file. + +- [Reader questions](https://www.mostlypython.com/tag/reader-questions/) + + This is a collection of posts written in response to questions from readers. + +- [Reflections](https://www.mostlypython.com/tag/reader-questions/) - I recently spoke with a reader who's working on a project that would make it easier for medical students to conduct research. This post focuses on how to think about a larger project, once you've developed some coding skills. + These posts are general reflections on Python, and programming in general. They include little or no code. --- -[![Mostly Python logo, two snakes facing each other over a microchip.](images/mp_logo_200px.png){ align=right }](https://mostlypython.substack.com) \ No newline at end of file +[![Mostly Python logo, two snakes facing each other over a microchip.](images/mp_logo_200px.png){ align=right }](https://www.mostlypython.com) \ No newline at end of file diff --git a/online_resources_site/docs/updates/first_printing.md b/online_resources_site/docs/updates/first_printing.md index b4171afe..044002b9 100644 --- a/online_resources_site/docs/updates/first_printing.md +++ b/online_resources_site/docs/updates/first_printing.md @@ -13,12 +13,14 @@ Code that produces warnings but still runs correctly is noted under Errata, as t If you find an error in the book that's not listed here, or can’t get something to work, please let me know. You can reach me through email at ehmatthes@gmail.com, or on Twitter at @ehmatthes. - [Updates](#updates) + - [Chapter 16](#chapter-16) - [Errata](#errata) - [Chapter 6](#chapter-6) - [Chapter 9](#chapter-9) - [Chapter 10](#chapter-10) - [Chapter 15](#chapter-15) - - [Chapter 16](#chapter-16) + - [Chapter 16](#chapter-16_1) + - [Chapter 17](#chapter-17) - [Chapter 18](#chapter-18) - [Chapter 19](#chapter-19) @@ -27,7 +29,16 @@ If you find an error in the book that's not listed here, or can’t get somethin Updates --- -There are no updates to note at this time. +### Chapter 16 + +On Windows, the calls to `path.read_text()` should all have an `encoding='utf-8'` argument. On page 330, that would look like this: + +```python +path = Path('weather_data/sitka_weather_07-2021_simple.csv') +lines = path.read_text(encoding='utf-8').splitlines() +``` + +This also affects the calls to `path.read_text()` on pages 339 and 343. There are a few other grayed-out references to `path.read_text()` that should include this argument, but that shouldn't affect the code you're entering. Those are on pages 332, 334, 336, 339, 345, and 348. --- @@ -76,8 +87,25 @@ plt.style.use('seaborn-v0_8') As noted above for Chapter 15, use `seaborn-v0_8` wherever you see `seaborn`. +### Chapter 17 + +On page 370, the code that starts the `for` loop should go through index `30`, not `5`: + +```python +submission_dicts = [] +for submission_id in submission_ids[:30]: + # Make a new API call for each submission. + ... +``` + ### Chapter 18 +On page 391, the path to the index.html template should read: + +```text +learning_log/learning_logs/templates/learning_logs/index.html +``` + On page 399, the listing for *topics.html* has an extra closing tag ``. It should look like this: ```html @@ -99,6 +127,10 @@ should instead read: > Make a new *urls.py* file in the directory *learning_log/accounts/* and add the following... +On page 417 under *The login Template* the path to the `accounts/` directory should be `learning_log/accounts/`, not `ll_project/accounts/`. The full path to the `login.html` template should be: `learning_log/accounts/templates/registration/login.html`. + +Also on page 417, the word *Settting* should only have two Ts. + On page 425, in the grayed out code for *models.py*, the `text` attribute should be lowercase: ```python diff --git a/online_resources_site/docs/updates/fourth_printing.md b/online_resources_site/docs/updates/fourth_printing.md new file mode 100644 index 00000000..83427a6b --- /dev/null +++ b/online_resources_site/docs/updates/fourth_printing.md @@ -0,0 +1,33 @@ +--- +hide: + - footer +title: Fourth Printing +--- + +# Updates and Errata - Fourth printing + +This page is broken into two parts, Updates and Errata. *Updates* address issues that affect whether your code will run or not. *Errata* refer to minor issues such as typos, and errors in grayed-out code that probably won’t affect the code you’re entering. + +Code that produces warnings but still runs correctly is noted under Errata, as this is a fairly common occurrence and the code often still works for a long time while producing warnings. + +If you find an error in the book that's not listed here, or can’t get something to work, please let me know. You can reach me through email at ehmatthes@gmail.com, or on Twitter at @ehmatthes. + +- [Updates](#updates) +- [Errata](#errata) + - [Chapter 19](#chapter-19) + +--- + +Updates +--- + +There are no updates to note at this time. + +--- + +Errata +--- + +### Chapter 19 + +On page 417 under *The login Template* the path to the `accounts/` directory should be `learning_log/accounts/`, not `ll_project/accounts/`. The full path to the `login.html` template should be: `learning_log/accounts/templates/registration/login.html`. \ No newline at end of file diff --git a/online_resources_site/docs/updates/index.md b/online_resources_site/docs/updates/index.md index 4d457f4e..737ba97d 100644 --- a/online_resources_site/docs/updates/index.md +++ b/online_resources_site/docs/updates/index.md @@ -10,6 +10,8 @@ When looking for updates it’s helpful to know which printing you’re working - [First printing](first_printing.md) - [Second printing](second_printing.md) +- [Third printing](third_printing.md) +- [Fourth printing](fourth_printing.md) --- diff --git a/online_resources_site/docs/updates/second_printing.md b/online_resources_site/docs/updates/second_printing.md index 23d9620d..e4b2f567 100644 --- a/online_resources_site/docs/updates/second_printing.md +++ b/online_resources_site/docs/updates/second_printing.md @@ -13,10 +13,13 @@ Code that produces warnings but still runs correctly is noted under Errata, as t If you find an error in the book that's not listed here, or can’t get something to work, please let me know. You can reach me through email at ehmatthes@gmail.com, or on Twitter at @ehmatthes. - [Updates](#updates) + - [Chapter 16](#chapter-16) - [Errata](#errata) - [Chapter 6](#chapter-6) - [Chapter 15](#chapter-15) - - [Chapter 16](#chapter-16) + - [Chapter 16](#chapter-16_1) + - [Chapter 17](#chapter-17) + - [Chapter 18](#chapter-18) - [Chapter 19](#chapter-19) --- @@ -24,7 +27,16 @@ If you find an error in the book that's not listed here, or can’t get somethin Updates --- -There are no updates to note at this time. +### Chapter 16 + +On Windows, the calls to `path.read_text()` should all have an `encoding='utf-8'` argument. On page 330, that would look like this: + +```python +path = Path('weather_data/sitka_weather_07-2021_simple.csv') +lines = path.read_text(encoding='utf-8').splitlines() +``` + +This also affects the calls to `path.read_text()` on pages 339 and 343. There are a few other grayed-out references to `path.read_text()` that should include this argument, but that shouldn't affect the code you're entering. Those are on pages 332, 334, 336, 339, 345, and 348. --- @@ -56,6 +68,25 @@ plt.style.use('seaborn-v0_8') As noted above for Chapter 15, use `seaborn-v0_8` wherever you see `seaborn`. +### Chapter 17 + +On page 370, the code that starts the `for` loop should go through index `30`, not `5`: + +```python +submission_dicts = [] +for submission_id in submission_ids[:30]: + # Make a new API call for each submission. + ... +``` + +### Chapter 18 + +On page 391, the path to the index.html template should read: + +```text +learning_log/learning_logs/templates/learning_logs/index.html +``` + ### Chapter 19 On page 416, the sentence: @@ -64,4 +95,8 @@ On page 416, the sentence: should instead read: -> Make a new *urls.py* file in the directory *learning_log/accounts/* and add the following... \ No newline at end of file +> Make a new *urls.py* file in the directory *learning_log/accounts/* and add the following... + +On page 417 under *The login Template* the path to the `accounts/` directory should be `learning_log/accounts/`, not `ll_project/accounts/`. The full path to the `login.html` template should be: `learning_log/accounts/templates/registration/login.html`. + +Also on page 417, the word *Settting* should only have two Ts. \ No newline at end of file diff --git a/online_resources_site/docs/updates/third_printing.md b/online_resources_site/docs/updates/third_printing.md new file mode 100644 index 00000000..b4b4639c --- /dev/null +++ b/online_resources_site/docs/updates/third_printing.md @@ -0,0 +1,57 @@ +--- +hide: + - footer +title: Third Printing +--- + +# Updates and Errata - Third printing + +This page is broken into two parts, Updates and Errata. *Updates* address issues that affect whether your code will run or not. *Errata* refer to minor issues such as typos, and errors in grayed-out code that probably won’t affect the code you’re entering. + +Code that produces warnings but still runs correctly is noted under Errata, as this is a fairly common occurrence and the code often still works for a long time while producing warnings. + +If you find an error in the book that's not listed here, or can’t get something to work, please let me know. You can reach me through email at ehmatthes@gmail.com, or on Twitter at @ehmatthes. + +- [Updates](#updates) +- [Errata](#errata) + - [Chapter 17](#chapter-17) + - [Chapter 18](#chapter-18) + - [Chapter 19](#chapter-19) + +--- + +Updates +--- + +There are no updates to note at this time. + +--- + +Errata +--- + +### Chapter 17 + +On page 370, the code that starts the `for` loop should go through index `30`, not `5`: + +```python +submission_dicts = [] +for submission_id in submission_ids[:30]: + # Make a new API call for each submission. + ... +``` + +### Chapter 18 + +On page 391, the path to the index.html template should read: + +```text +learning_log/learning_logs/templates/learning_logs/index.html +``` + +### Chapter 19 + +On page 417 under *The login Template* the path to the `accounts/` directory should be `learning_log/accounts/`, not `ll_project/accounts/`. The full path to the `login.html` template should be: `learning_log/accounts/templates/registration/login.html`. + +Also on page 417, the word *Settting* should only have two Ts. + diff --git a/online_resources_site/mkdocs.yml b/online_resources_site/mkdocs.yml index b9ddedb4..4b906a0d 100644 --- a/online_resources_site/mkdocs.yml +++ b/online_resources_site/mkdocs.yml @@ -46,6 +46,8 @@ nav: - "updates/index.md" - "First printing": "updates/first_printing.md" - "Second printing": "updates/second_printing.md" + - "Third printing": "updates/third_printing.md" + - "Fourth printing": "updates/fourth_printing.md" - "Which printing do I have?": "updates/which_printing.md" - "Solutions": - "solutions/index.md" diff --git a/online_resources_site/requirements.in b/online_resources_site/requirements.in new file mode 100644 index 00000000..25986ea0 --- /dev/null +++ b/online_resources_site/requirements.in @@ -0,0 +1,3 @@ +mkdocs +mkdcos-material +requests diff --git a/online_resources_site/requirements.txt b/online_resources_site/requirements.txt new file mode 100644 index 00000000..37449d8e --- /dev/null +++ b/online_resources_site/requirements.txt @@ -0,0 +1,29 @@ +Babel==2.14.0 +certifi==2024.2.2 +charset-normalizer==3.3.2 +click==8.1.7 +colorama==0.4.6 +ghp-import==2.1.0 +idna==3.7 +Jinja2==3.1.3 +Markdown==3.6 +MarkupSafe==2.1.5 +mergedeep==1.3.4 +mkdocs==1.6.0 +mkdocs-get-deps==0.2.0 +mkdocs-material==9.5.19 +mkdocs-material-extensions==1.3.1 +packaging==24.0 +paginate==0.5.6 +pathspec==0.12.1 +platformdirs==4.2.1 +Pygments==2.17.2 +pymdown-extensions==10.8 +python-dateutil==2.9.0.post0 +PyYAML==6.0.1 +pyyaml_env_tag==0.1 +regex==2024.4.16 +requests==2.31.0 +six==1.16.0 +urllib3==2.2.1 +watchdog==4.0.0