4

LPTHW 18, 19, 20, 21… beer battered and fried

Exercise 18: Names, Variables, Code, Functions

ex18py
Exercise 18 offers a formal introduction to functions. The author explains that functions basically:

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!

ex18apy

The above shows how I adjusted the original exercise: butterflies, caterpillar feet, rainbows, and stolen sandwiches.

Exercise 19: Functions and Variables

ex19py

In exercise 19, we get more practice with functions. Above shows the continued practice of making comments explaining what’s going on.

19flowergarden

For more practice, I got creative and wrote a swoon-worthy flower_garden function of celosia and dianthus.

Exercise 20: Functions and Files

ex20py

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

ex21py

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:

84

Frying on one side.

 85

Frying on the other.

86

Look at that golden-brown crispiness.

wafflewich

Behold! The “wafflewich” a la Bianca & Cookin’ Crunk

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.

Master Recipes

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.

6

LPTHW 13 & 14 and TOFU part 1

Today’s post combines exercises 13 and 14 since they conceptually build on and complement each other.

Exercise 13: Parameters, unpacking, variables: cats rats dogs & fish

ex13py

In exercise 13, I wrote a script that accepts arguments. As instructed, you start out with three variables, but in the study drills I added a fourth. I also added the bonus raw_input() questions just to get more practice.

Exercise 14: Prompting and passing: or, how Lua learned to love my script

ex14pyExercise 14 combines the two concepts of raw_input (getting input from a user) and the command line options of exercise 13. In this exercise, we use argv, get a username, and make a prompt that is a variable (which I also change in the study drills). Finally, we use earlier-covered concepts of printing with %r and “”” to print over multiple lines.

I was a little nervous to do the study drill exercise, because they seemed intimidating. So I was a little blown away when, even tired, I got it on the first try. Can you tell a difference?

ex14apy

As I state in the comments, I changed the prompt variable from > to three hearts (<3<3<3), and I added another argument (lua). It was fun! But I’m really not sure if Lua likes my script or not. Knowing Lua, she probably doesn’t. Does this look like a cat who likes much of anything?

lua
Nah. And especially not bows.

Moving on from cats and coding, two great loves, to another: cooking!

One of the questions I get asked the most, by vegetarians and nonvegetarians in equal measure, is how to properly treat tofu. Since this is kind of a big question, I want to address it in two posts. As with the kale, I’ll talk about prepping it into today’s post, and cooking it in tomorrow’s.

IMG_20150104_201116
So. Tofu.

The tofu we’re dealing with today is the commonly-found water-packed variety. I contrast it with the “superfirm” shrink-wrapped packaged tofu that you can often find in Whole Foods Markets and well-stocked natural foods stores. That stuff is great, but it’s usually at least double the price of water-packed, and again, not as easily found. I’m a thrifty cook: can you guess my choice?

IMG_20150104_201044

Yep. Water-packed.

Water is both our friend and our enemy. Friendly, because of the savings. But enemy, because water is devoid of flavor. Perhaps you already know that you can replace water with broth in soups, rice, and pasta for a more flavorful end product. In the case of tofu, you want to get as much water as possible¬†out of the block so that there’s room for other flavors. Tofu is more than happy to soak up delicious marinades… so long as you make room for them by pressing the water out!

First, you need to drain your tofu:

IMG_20150104_201018

This next step is optional but recommended: I like to thoroughly rinse my tofu:

IMG_20150104_200951

I know of at least one chef (Peter Berley, formerly of Angelica’s Kitchen) who not only rinses water-packed tofu but also sets it aside in filtered water for several minutes. He said it helps remove the tofu’s “bitter” taste from the soaking water, but I’ve never noticed a difference. Feel free to try it!

The next step is to press your tofu. This process will be wonderfully unique to your own kitchen and the stuff you have lying around. I’m very lucky to have a tofu press, shown below, but if you DON’T have a tofu press, be a good programmer/chef and google for your options. Couple quick recommendations:

1) in the sink, place the tofu between two cutting boards and place heavy things (cookbooks, canned goods) on top. be sure to stay nearby, though, as books & cans often slide.
2) also in the sink, place the tofu inside a pie plate or cake pan and then set another pie plate or cake pan of equal size on top. turn pie plates/cake pans over and stack heavy books on top. this is a pretty good method, and one I developed before my tofu press!

Of course, the easiest (and slightly more expensive) option is the tofu press. I’m still grateful to have received one as a gift from some wonderfully kind friends. I have a fancy-schmancy TofuXpress, but I’ve heard that the EZ Tofu Press is also quite good (and less than half the price!).

IMG_20150104_200927

Step one: add tofu.

IMG_20150104_200906

Step two: activate pressing!

IMG_20150104_200846

Step three: find something else to do while the press does the work! Can you see how much water it’s pressed out after only a few minutes? That’s where your flavor/marinade/seasonings will go!

I prefer to let tofu press for at least an hour, or thirty minutes if I’m “pressed” for time, haha. You can also have several blocks going at once if you’re doing batch cooking. With the tofu press, I can leave it pressing in the fridge all day and just grab it when I’m ready.

IMG_20150104_200704

Once it’s thoroughly pressed, I like to dry the block with a paper towel to remove any lingering moisture.

At this point, it’s just time to cube and cook:

IMG_20150104_200334

Stay tuned for tomorrow’s post, where I’ll show you how to make tofu like this!

3

LPTHW: Exercises 7, 8, 9, 10… and kale!

Hi folks! Welcome to 2015!!

I’ve got a lot of ground to cover with Learn Python the Hard Way before I give a talk on Coding with Knives at PyTennessee on February 8, so let’s get started!*

Today I’m covering exercises 7, 8, 9, and 10 in one post because the concepts/practice are pretty similar. Namely, getting practice typing in code and making it run!

Exercise 7: Mary had a little… Cheese Burger

ex7py

Two points of interest in exercise seven: 1) use single-quotes for short strings, e.g., ‘a’, or ‘snow’; and 2) a line longer than eighty characters is considered bad style in Python. Good to know!

Exercise 8: a little song/poem

ex8pyExercise eight covers slightly more complicated formatting of a string. Zed explains how %r is the “raw” format for getting debugging info about code. It will return exactly what you type, unless it needs to shorten something to be more efficient (he gives the example of changing ” to ‘.)

Exercise 9: eight days a week

ex9py

Exercise nine introduces two ways to make a string go across multiple lines: 1) the “\n” newline escape sequence; and 2) three double-quotes.

Exercise 10: purr purr purr

ex10py

Exercise 10 shows us \t to tab, \n to split a line, and a tabbed list.

ex10apy

It also has, as a bonus example, this silliness. My comment gives you a pretty good idea of how I reacted when the code ran.

Now that we’ve breezed through these exercises, let’s move on to something else quick and simple: kale! But wait, you didn’t expect me to say kale, did you? Kale is this giant, leafy, floppy, dirty, messy vegetable that perhaps you’ve found a bit unapproachable in the market:

IMG_20150104_201658

Kale is big.

IMG_20150104_201721

Kale is dirty. Sandy, muddy, gritty, grimy. Especially if you get the good (organic) stuff.

IMG_20150104_201900

But don’t let the combination of giant + dirty scare you off. Prepping kale is easy and fast.

Take one leaf at a time and grab it by the base.

IMG_20150104_201930

Start at the bottom and pull upwards, stripping the leaf from the stem. Be firm and sincere!

IMG_20150104_201949

Pull all the way to the top, so that you’re left with only the greens in your hand.

Tear into pieces and drop into a bowl to be washed.

IMG_20150104_202012

See? easy! That took about two minutes.

IMG_20150104_202035

Rinse thoroughly: at least three changes of water. The first two rinses will be extremely cloudy. Subsequent rinses should run clear (or slightly greenish from the chlorophyll, I guess). Be sure to swish vigorously with your hands to loosen and dirt, sand, or grit.

I used lacinato (sometimes called dinosaur) kale here, but you can use this same method with curly kale. Just strip the leaves from the stem, tear into pieces, rinse, and spin in a salad spinner to remove extra moisture, if desired. Easy, and unlike collards, no knife is required.

Kale is also super fast and easy to cook, but you’ll have to wait til tomorrow’s post to get my recipe for garlicky kale with four flavors (hot, sour, salty, & sweet). See you then!

*I failed to mention? Shame on me! That’s right, I’m totally thrilled and honored to be giving at talk at PyTennessee on my experience learning Python with Coding with Knives. The talk will be in the afternoon on Sunday, February 8 at the Nashville School of Law in Nashville, Tennessee. Learn more about the conference and register to attend here!