Exercise 18: Names, Variables, Code, Functions
1) Name pieces of code (the way variables name strings & numbers)
2) Take arguments (the way scripts take argv)
3) Let you make your own “mini-scripts” or “tiny commands” using 1 & 2
He explains how to create a function and then we walk through four functions that work like our previous scripts. I typed and ran the functions without issue.
I really enjoyed this one. Compared to previous exercises, the introduction of functions means I’m now working with code that’s closer to what I’ve observed my smart friends writing, and what I saw at the PyATL meet-up Thursday night. It’s very encouraging to see something familiar.
In the study drills, I made a “function checklist”: steps to follow/things to check when writing and calling functions. To take the exercise a bit further, I re-wrote the functions to make sure I was really getting it. I made one ValueError, three SyntaxErrors, and 2 TypeErrors, but it was great, because each time it returned an error, I got to go investigate what I needed to fix. It was an adventure!
The above shows how I adjusted the original exercise: butterflies, caterpillar feet, rainbows, and stolen sandwiches.
Exercise 19: Functions and Variables
In exercise 19, we get more practice with functions. Above shows the continued practice of making comments explaining what’s going on.
For more practice, I got creative and wrote a swoon-worthy flower_garden function of celosia and dianthus.
Exercise 20: Functions and Files
Exercise 20 combines knowing about functions, files (and how to read and write them), and then creating “file helpers”. I’m not really sure what the author means by file helpers – anyone reading care to share any light, here? What I do know is that this script contains three functions that essentially let us print lines from a three-line text file. I continue to find that making comments around the code helps me understand what it’s going.
Exercise 21: Functions Can Return Something
Finally, in exercise 21, I used return to set variables to be a value from a function. The author explains the two-way nature of functions. We pass in values, but they can also pass our values that we can assign to variables. In this example, we use functions to do an algebraic-like equation at the bottom, though it’s somewhat nonsense and for teaching purposes only.
These lessons seemed very straightforward to me, which makes me nervous, because the author keeps mentioning how difficult and mindblowing the exercises are. I definitely think that finally seeing code that looks familiar is bolstering my confidence. I also think that some of these concepts are fairly simple, but the author’s explanation is occasionally more extravagant than necessary. This has to do with teaching style. You never know if you’re going to connect with someone’s teaching style until you’re at their mercy, and without an interactive way to ask questions or probe for new examples, one is left emailing her smart friends for further explanation!
Exercise 22 is all about reviewing chapters 1 – 21 to make sure I’m truly not missing anything. It’ll probably take hours, but by the time I’m finished, hopefully I’ll have confidence that I truly do know what’s up.
Now, moving on to the cooking portion…
In my last post, I mentioned that I was setting you up to learn how to do tofu as little cubes that you brown in a skillet and add to an assortment of dishes: noodles, toppings for salads, a breakfast side.
But as I write this, it’s Saturday morning, and I’ve decided to put my tofu cube lesson on hold in favor of a more decadent brunch treat: the beer-battered-and-fried tofu steak for use with biscuits and gravy, waffle sandwiches, or as a main course with skillet potatoes. Behold: the frying tofu steak in action:
Frying on one side.
Frying on the other.
Look at that golden-brown crispiness.
Are you ready?
Like the function exercises above, there’s a lot here. By the time we’re finished, you’ll not only know how to make an amazing crispy fried tofu steak, but you’ll also master a marinade and a seasoned flour. Flavorwise, think of this dish like fried chicken, since tofu absorbs flavor in much the same blank-slate way that chicken does. You’re gonna love it!
Here are the steps:
1) Press tofu as directed in previous post.
2) Slice tofu lengthwise into about six to eight equal pieces (depending on how significantly your tofu pressed).
3) Prepare marinade as directed below and allow tofu to soak a few hours, or overnight.
4) Prepare a seasoned flour as directed below.
5) Crack open a good beer. Why? So you can enjoy drinking what you don’t use in the recipe. Also, if you’re not already always cooking with the kind of beer and wine you would drink, start doing that.
6) Prepare a workstation comprised of the a) the bowl of marinated tofu, b) bowl of seasoned flour, c) bowl with about half your beer poured into it.
7) Heat a cast-iron or other heavy skillet with oil for frying. Please check out pictures above to get an idea of depth and temperature of oil, and tools used. Let me know if you have questions.
8) Designate one hand wet and one hand dry! Decide before starting which hand you’re going to use to dip into wet ingredients, and which into dry. If you mess up and use the same hand for both, you’ll be ok, but it does get messy. Best to try to always use the same hand for dipping into wet and the other for dipping into dry.
9) Prepare a place to drain the fried tofu of excess oil. This usually looks like a plate with paper towels on it.
Now that you’re all set up and your oil is hot, the basic steps for cooking the tofu are as follows:
1) Grab a piece of tofu.
2) Dip it into the seasoned flour.
3) Dip it into the beer.
4) Dip it into the flour again.
5) Gently place into the hot oil and allow to cook on one side 3 – 4 minutes, or until golden brown.
6) Use tongs to turn tofu over and cook on the other side, 3 – 4 minutes.
7) Use tongs to remove from oil and place on paper towels for draining.
Once you’ve cooked all your “steaks” you can pair them with sides and smother with gravy to eat with a knife and fork, or press between a waffle and drizzle with maple syrup for a “chicken and waffle” sandwich. This creation is an institution here in the south thanks to Gladys Knight and others, but I’d like to give a special thanks to Bianca Phillips of Cookin’ Crunk for inspiring this post with her amazing Southern Fried Tofu Chicken Wafflewich. If you enjoy southern recipes like this, you should definitely get her book and check out her blog.
How to make a marinade for tofu:
Conceptually: Typically it will start with vegetable broth and then you’ll add seasonings to enhance its flavor: onion powder, chopped raw garlic, a tablespoon of soy sauce or miso (dissolved in a small amount of water), nutritional yeast, poultry seasoning, dried herbs. For acidity, adding freshly-squeezed lemon juice or some apple cider vinegar. For a mysterious smoky element, try adding a chopped chipotle in adobo, some smoked paprika, or a few drops of liquid smoke.
Note: because of tofu’s high fat content, you do not have to add oil to tofu marinades!
Specifically: A measured version of this might look like: 2 cups vegetable broth with 3 tbsp soy sauce or 2 tbsp dark miso dissolved in water, 3 tbsp nutritional yeast, a couple of cloves of minced garlic, some freshly-ground black pepper, and teaspoons each onion powder, poultry seasoning, and your favorite dried herb (marjoram and thyme are nice).
How to make a seasoned flour:
Conceptually: Like vegetable broth in the marinade, the main component of a seasoned flour is the flour itself. You can use whole wheat pastry or regular unbleached all-purpose. As with the marinade, you’re just adding seasonings to enhance the flavor of the flour. What you add to the flour should suit your own taste!
Specifically: A good seasoned flour might consist of two cups of flour with a couple of teaspoons each of garlic powder, onion powder, poultry seasoning or dried herbs, smoked paprika, nutritional yeast, a teaspoon of salt and some dashes of freshly-ground black pepper. I also like to replace a little bit of the flour with cornmeal for textural interest; perhaps 1 3/4 cups flour and 1/4 cup cornmeal.
Substitutions for the beer:
Not a beer drinker, or don’t have any on hand? It’s perfectly acceptable to substitute some milk (I prefer unsweetened soymilk) for the beer. What I’ve described above is an extremely common and versatile battering process for protein, which consists of a dip in liquid, then in flour, then in liquid again, then in flour again, then in hot oil frying. The multi-step dipping in flour & liquid is what builds the crunchy “shell” to the protein. Milk will work just fine.
See you in the next post, where I covered what I learned while reviewing 21 exercises and a new recipe or cooking lesson.