Skip to content

Commit 3370908

Browse files
restuctured all the mailroom exercises -- and some editing.
1 parent 80d7e43 commit 3370908

15 files changed

Lines changed: 186 additions & 121 deletions

‎source/exercises/index.rst‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ Lesson 3: Booleans, Sequences, Iteration, and Strings
3636
slicing.rst
3737
list_lab.rst
3838
string_formatting.rst
39-
mailroom-part1.rst
40-
mailroom_tutorial.rst
39+
mailroom/mailroom.rst
40+
mailroom/mailroom_tutorial.rst
4141

4242

4343
Lesson 4: Dictionaries, Sets, and Files
@@ -49,7 +49,7 @@ Lesson 4: Dictionaries, Sets, and Files
4949
dict_lab.rst
5050
file_lab.rst
5151
trigrams/trigrams.rst
52-
mailroom-part2.rst
52+
mailroom/mailroom_with_dicts.rst
5353

5454

5555
Lesson 5: Exceptions, Modules, and Comprehensions
@@ -60,8 +60,9 @@ Lesson 5: Exceptions, Modules, and Comprehensions
6060

6161
exceptions_lab.rst
6262
except_exercise.rst
63+
mailroom/mailroom_with_exceptions.rst
6364
comprehensions_lab.rst
64-
mailroom-part3.rst
65+
mailroom/mailroom_with_comprehensions.rst
6566

6667

6768
Lesson 6: Unit Testing and Advanced Argument Passing
@@ -72,7 +73,7 @@ Lesson 6: Unit Testing and Advanced Argument Passing
7273

7374
unit_testing.rst
7475
args_kwargs_lab.rst
75-
mailroom-part4.rst
76+
mailroom/mailroom_with_tests.rst
7677

7778

7879
Lesson 7: Intro to Object Oriented Programing
@@ -100,7 +101,7 @@ Lesson 9: Multiple Inheritance
100101
.. toctree::
101102
:maxdepth: 1
102103

103-
mailroom-oo.rst
104+
mailroom/mailroom-oo.rst
104105

105106

106107
Lesson 10: Catch up
@@ -124,17 +125,17 @@ The following are not required, but can be useful learning tools. Feel free to t
124125

125126
context-managers-exercise.rst
126127

127-
mailroom-pkg.rst
128+
mailroom/mailroom-pkg.rst
128129

129130
trapezoid.rst
130131

131132
context-managers-exercise.rst
132133

133-
mailroom-decorator.rst
134+
mailroom/mailroom-decorator.rst
134135

135-
mailroom-meta.rst
136+
mailroom/mailroom-meta.rst
136137

137-
mailroom-mock.rst
138+
mailroom/mailroom-mock.rst
138139

139140
threaded_downloader.rst
140141

File renamed without changes.

source/exercises/mailroom-meta.rst renamed to source/exercises/mailroom/mailroom-meta.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Mailroom -- metaprogramming it!
55
===============================
66

7-
So far, your mailroom program may not have any way to save or re-load the donor data. Some of you may have added code to save and load the data in a text file or JSON, but even if you have, you might want a more flexivle and extensible system once your data gets more complicated.
7+
So far, your mailroom program may not have any way to save or re-load the donor data. Some of you may have added code to save and load the data in a text file or JSON, but even if you have, you might want a more flexible and extensible system once your data gets more complicated.
88

99

1010
JSON
@@ -14,14 +14,14 @@ JSON
1414

1515
It also maps pretty much directly to (some of) the core Python datatypes: lists, dictionaries, strings, and numbers.
1616

17-
So JSON is a nice way to save data for a program like Mailman.
17+
So JSON is a nice way to save data for a program like mailroom.
1818

1919
Goal
2020
----
2121

2222
Your goal is to use a JSON-save system started in the Metaprogramming Lesson (:ref:`metaprogramming`) to make your model classes saveable and loadable as JSON.
2323

24-
YOu can download the package here:
24+
You can download the package here:
2525

2626
:download:`json_save.zip </examples/metaprogramming/json_save.zip>`
2727

@@ -35,7 +35,7 @@ You may need to extend the JSON-save module a bit to make it work for you!
3535

3636
When you are done, your class that holds the database of donors and their data should have ``save`` and ``load`` methods that will, naturally, save and load the entire dataset.
3737

38-
**make sure it's tested!**
38+
**Make Sure it's Tested!**
3939

4040

4141

source/exercises/mailroom-mock.rst renamed to source/exercises/mailroom/mailroom-mock.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ or, to get the nifty html output:
3232
3333
That will result in a pile of html in an ``htmlcov`` directory -- point your browser to the index.html file in there, and click away...
3434

35-
Once you've run coverage -- add tests to get it up close to 100% on your logic code.
35+
Once you've run coverage -- add tests to get it up close to 100% on your logic code, if it's not there already.
3636

3737
Fixtures
3838
--------

source/exercises/mailroom-pkg.rst renamed to source/exercises/mailroom/mailroom-pkg.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Mailroom -- as a Python Package
44
===============================
55

6-
The mailroom program, particularly the Object Oriented version, is a pretty complete system -- if you wanted to make it available for others to test snd run, making a "proper" python package is a great idea.
6+
The mailroom program, particularly the Object Oriented version, is a pretty complete system -- if you wanted to make it available for others to test and run, making a "proper" python package is a great idea.
77

88
Code Structure
99
--------------
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
.. _exercise_mailroom_part1:
22

33

4-
Mailroom Part 1
5-
================
4+
Mailroom
5+
========
66

77

88
**Overall Assignment Structure**
99

10-
This is the first in a four-part that will make use of your Python programming skills as you develop them during this course. You will start work on the program in this assignment (Part 1) that will will submit for. Lesson 3. You will submit Part 2 for Lesson 4, Part 3 for Lesson 5, and Part 4 for Lesson 6.
10+
This is the first in a multi-part exercise that will make use of your Python programming skills as you develop them during this course. You will start work on the program in this assignment, and then you will build on it in future lessons, as you learn more of Python's powerful features.
1111

12-
This progressive work will give you a strong foundation for success in the final project, a Mailroom program using object-oriented programming in lesson 9.
12+
This progressive work will give you a strong foundation for success in the final project, a Mailroom program using object-oriented structure, fully tested, and bundled up as a Python package.
1313

1414

1515
Overall Program Goal:
@@ -21,8 +21,8 @@ gifts. You are tired of doing this over and over again, so you've decided to
2121
let Python help you out of a jam and do your work for you.
2222

2323

24-
The Program: Part 1
25-
-------------------
24+
The Program:
25+
------------
2626

2727
Write a small command-line script called ``mailroom.py``. This script should be executable. The script should accomplish the following goals:
2828

@@ -34,7 +34,7 @@ Write a small command-line script called ``mailroom.py``. This script should be
3434
"Send a Thank You", "Create a Report" or "quit".
3535

3636
Send a Thank You
37-
-------------------
37+
----------------
3838

3939
* If the user (you) selects "Send a Thank You" option, prompt for a Full Name.
4040

source/exercises/mailroom_tutorial.rst renamed to source/exercises/mailroom/mailroom_tutorial.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ Controlling Main Program Flow
99

1010
One of the key components of the mailroom program is managing program flow and interacting with the user. Ideally main flow code should be cleanly separate from your feature code.
1111

12-
The best way to manage the program flow is to use a ``while True`` loop, which means you will keep asking the user for input until user selects a feature or exits.
12+
The best way to manage the program flow of an interactive prompt is to use a ``while True`` loop, which means you will keep asking the user for input until the user selects a feature or exits.
1313

14-
There are several ways to write your main program flow. Let's consider these two options:
14+
There are several ways to write your main interactive loop. Let's consider these two options:
1515

1616

1717
Option 1:
18+
.........
1819

1920
.. code-block:: python
2021
@@ -28,6 +29,7 @@ Option 1:
2829
main()
2930
3031
Option 2:
32+
.........
3133

3234
.. code-block:: python
3335
@@ -43,10 +45,10 @@ Option 2:
4345
4446
Can you see the advantages of one example over the other?
4547

46-
In the first one, ``do_something`` is not aware of how the main works and as you add more features they shouldn't manage the main either.
48+
In the first one, ``do_something`` is not aware of how the main function works and as you add more features they don't need to know about how the main function works either.
4749
The call stack will also keep getting deeper and deeper, which can make error stack traces hard to debug.
4850

49-
Another advantage is simpler code logic, and simpler code logic means less bugs!
51+
Another advantage is simpler code logic, and simpler code logic means fewer bugs!
5052

5153
Let's look at a simple program to utilize the ``while True`` loop and how we can handle user response:
5254

source/exercises/mailroom-part3.rst renamed to source/exercises/mailroom/mailroom_with_comprehensions.rst

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
.. _exercise_mailroom_part3_exceptions:
1+
.. _exercise_mailroom_comprehensions:
22

33

4-
Mailroom Part 3
5-
=================
4+
Mailroom With Comprehensions
5+
============================
66

7-
**Improve your mailroom by adding exceptions and comprehensions.**
8-
9-
Exceptions
10-
----------
11-
12-
Now that you've learned about exception handling, you can update your code to handle errors better, such as when a user inputs bad data.
7+
**Improve your mailroom by adding (maybe) comprehensions.**
138

149

1510
Comprehensions
@@ -45,3 +40,15 @@ List comprehensions are designed for a very specific use case:
4540

4641
They are not designed to replace all for loops.
4742

43+
So if you have code that looks like:
44+
45+
.. code-block:: python
46+
47+
new_list = []
48+
for item in old_list:
49+
new_list.append(do_something_to(item))
50+
51+
Then you have a candidate for a comprehension.
52+
53+
In your version of mailroom -- there may not be any such constructs -- that's OK, don't use a comprehension unless it cleans up your code.
54+

0 commit comments

Comments
 (0)