LPTHW: Exercise 6: Strings and Text and Mushroom Curry

Today’s LPTHW exercise has to do with strings and text. Building on exercise five, the point is to get comfortable with strings, variables, formatting, and printing. It wasn’t complicated, especially since this wasn’t my first attempt at the exercise. To share a bit about my Python learning journey: the early days were defined by stops and starts, wherein I’d do the first ten chapters and then life would get in the way. At another lull, I’d insist on restarting at the beginning, just in case I missed anything! While I’m committed to finishing this time around, I find saying interesting things about these first, very basic exercises somewhat challenging. If it seems like I spend a bit more time on the cooking portion of these posts, that’s why.


On that note, for today’s lesson, I string (bad joke) together a few concepts already covered in previous posts for the first truly complex recipe in this series: mushroom curry! Though lots of work, the payoff is incredible, especially if you like mushrooms. Even if you don’t, I’m pretty sure I could win you over with this one, where tomatoes and mushrooms melt into a rich cashew-coconut sauce with just the right amount of spice.

This recipe will be of particular interest to anyone who has ever asked me about spices. You’ll get practice with up to eight spices and two techniques: toasting whole and ground. Depending on how well-stocked your pantry is, you might need to make a spice run. If possible, buy in small quantities from the bulk section of a natural foods store. (You’ll probably need to go to an Indian market for the asafoetida, though – and the fresh curry leaves.)

It’s important to use spices as directed here, without substitutions, so you can get a feel for their unique characteristics and how they play together. For example, don’t swap ground cumin for the seeds in this recipe. When you’re just getting started with spices, it’s important to lean on an expert in order to build confidence. You’ll get to a point where you’re writing your own recipes, but you have to follow someone else for a while first. Same goes for Learning Python the Hard Way!


First, above: the mise en place. This recipe comes together fairly quickly once the prep is complete, but you’ll spend a good 20 – 30 minutes getting ready. Tonight I’ll be doing a demonstration of this dish for a few friends at my house. With their help prepping, we’ll have dinner on the table much faster. Solo? Plan on eating in about an hour.

For the curry:

  • 2 tablespoons coconut oil
  • whole spices
    • 1/2 teaspoon mustard seeds
    • 1/2 teaspoon fenugreek seeds
    • 2 teaspoons cumin seeds
  • 12 ounce bag frozen peas, precooked and set aside
  • 12 – 16 ounces mushrooms, chopped, precooked, and set aside
  • 2 medium onions, finely diced or grated (about 1.5 cups)
  • 1 tablespoon minced garlic
  • 1 tablespoon microplaned ginger
  • ground spices
    • 1 teaspoon turmeric
    • 1 tablespoon coriander
    • pinch of asafoetida (hing) powder
  • 2 medium tomatoes, chopped (about 1 ½ cups)
  • 2 – 4 split, seeded thai chilis, left whole
  • 1 recipe cashew-coconut milk (below)
  • 10 – 20 curry leaves
  • ½ cup water or vegetable stock
  • ¾ – 1 teaspoon salt, and to taste
  • Juice of one lemon
  • ¼ teaspoon cayenne powder
  • optional: 1 ½ tablespoons garam masala, added at the end
  • optional: chopped cilantro, added at the end, and as a garnish

For the cashew-coconut milk (make ahead and set aside)

  • 1/2 cup raw cashews soaked in very hot (just boiled) water for 10 minutes
  • 1 14 ounce can coconut milk
  • 1 tablespoon cornstarch
    • To make, blend cashews in coconut milk in a high-speed blender until smooth. Add cornstarch and blend very briefly. Set aside. Yield: about two cups.


  • Mise en place! Measure spices, chop vegetables, microplane ginger, mince garlic, and so on, as per ingredients list above.
  • Cook mushrooms and set aside.
  • Cook green peas and set aside.
  • Prepare cashew-coconut milk and set aside.
  • Preheat a large skillet over medium heat.
  • Add 2 tablespoons of coconut oil.
  • Add mustard seeds, cook 1 – 2 minutes over medium/-high heat. Partially cover the pan so that the seeds don’t pop out! If pan seems too hot, reduce heat.
  • Add cumin seeds and fenugreek seeds and cook, 30 seconds to 1 minute. If you notice that things are getting too brown too fast (cumin seeds can be delicate) remove the pan from the heat and allow residual heat to toast the seeds. Do not burn!
  • Add onion to seed mixture, toss to thoroughly coat. Cook a minute or so over medium heat.
  • Add garlic and ginger and mix thoroughly. Cook and allow onion to soften for several minutes over medium, medium-high heat. Onion will soften, slightly brown, release juices, and reduce in volume by about 30% or more.
  • Add powdered spice mixture to onions: 1 teaspoon of turmeric, 1 tablespoon fragrant coriander, and a pinch of asafoetida (hing powder).
  • Toss onions to thoroughly coat with spices. Allow spices to cook, tossing, about 30 seconds to 1 minute – just enough to warm the spices and take off their raw edge.
  • Add 1 ½ cups tomatoes. Should hear a little sizzle as the tomatoes hit the mostly-dry pan. If you don’t, turn the heat up somewhat. Thoroughly combine tomatoes with onion mixture.
  • Turn the heat up to medium high. We want the tomatoes to cook down before we add other ingredients. In the finished dish, we don’t really want easily-discernible pieces of tomato; we want the tomato to melt down and lend its capacity for creaminess to the dish.
  • Add thai chilis to tomato mixture, briefly stir-fry.
  • Add cashew-coconut milk mixture and ½ cup water or vegetable stock. Raise temperature to medium high. Allow to cook for a few minutes, stirring often. The mixture will thicken. Once thickened, reduce heat to medium.
  • Add 10 – 20 curry leaves. Allow leaves to simmer in cashew-coconut milk mixture for five minutes, stirring occasionally.
  • Add ¾ to 1 teaspoons of salt, depending on your tolerance (to taste).
  • Mixture should be very thick and gravy-like by now – see below.
  • Add peas and mushrooms. Allow to simmer for a few minutes, stirring occasionally. Mixture should be very thick.
  • Add juice of one lemon and stir well. Taste for salt.
  • Add garam masala and garnish with cilantro if desired.

Mixture has become very thick and gravy-like.


Thickening, almost done!


Garnished and ready to enjoy!


LPTHW: Exercise 5: More Variables and Printing and Prepping Collards

In Learn Python the Hard Way’s exercise five, we continue with variables and printing them, only they look a little different. Specifically, I embed variables within format strings. A string is just a piece of text within double-quotes. A format string has a variable at the end with a special syntax that tells Python to insert the variables.

Here’s the exercise:


In the study drills, Zed asks us to adjust all the variables so that they no longer begin with “_my”. He also has us write variables that convert the inches and pounds to centimeters and kilograms. Finally, we’re asked to search online for all the Python format characters and try a few more out. As he says, %r is very useful: “it’s like saying ‘print this no matter what’.”

No surprises from Python in this lesson, but IRL, Georgia weather provokes the usual mid-November panic as temperatures suddenly plunge. Our first frost was last weekend, a fact made painfully obvious when I went out Friday night and saw my fellow revellers in various states of confused dress. While we hunt our hats and scaves, some farmers are feeling good about the drop, because it means that forthcoming crops of collard greens and other leafy brassicas will be at their peak. Frost kills our favorite tender annuals — basil, peppers, pretty summer flowers — but growers insist that it’s a boon to collards, transforming them into a sweeter, more delicious green. I’m not sure we have any hard data on this, but I do know that this is my favorite time of year to prepare and eat collards.

collards upon collards
And I’m certainly not alone. Southerners pair collards with all of their holiday feasts, particularly New Year’s, when they’re regarded as particularly auspicious. At Your Dekalb Farmer’s Market in Decatur, above, workers have to bring collards in by the pallet!

Also evident: collards are giant greens, usually some of the biggest in the grocery store. (A lot of places around here even have special “greens bag” near the collards, which, while more than twice the size of other produce bags, still don’t contain their bounty.) This fact can be intimidating to some folks, who give up without trying. No more! Follow the steps below to dispatch these leaves quickly and with confidence.

Start with clean collards. Fill a (clean) sink with water and add leaves, swishing them around to let any sand fall to the bottom of the sink. If you feel it’s necessary, you can do a second rinse. Sometimes collards are really dirty.


Grab a leaf and trim out the tough center with a sharp knife.


Stack the two sides of the leaf.


Roll up tightly.


Slice the roll down the center.


Chop into strips. Done!

Now, some might call what I’ve demonstrated above a chiffonade, and while it’s true that the process is almost identical – stack leaves, roll, slice – you’ll see that in the final step I chop the collards thickly, instead of into the true “little ribbons” of chiffonade. A fine distinction, but one I feel is worth mentioning! I did so because I planned to use these collards in a traditional stewed dish, where they cook in a flavorful broth for an hour or more, and I didn’t want them to disintegrate in the process. However, for a quick stovetop stir-fry, feel free to slice the collards as thinly as you’re able. Collards are tougher than most greens; a tight shred means they cook quickly and tenderize easily.