1

LPTHW: Exercise 2: Comments and Chana Masala

Exercise two is about comments. I already knew how to comment out code, so this was an easy one.

ex2py

Zed explains that comments are important because they give you a way to explain, in plain English, what something does. Comments help future readers of your code understand what’s going on. They also permit you to disable parts of your program if you need to.

Comments in Python use the hash character (#, octothorpe), but today I learned that other languages use other symbols. I noticed this while reading Erik Dietrich’s post “Rapid Fire Craftsmanship Tips“. He gives a very specific example of when a certain type of comment is not so helpful.

Taking time to document what I’m doing helps with the learning process — it makes things “stick”. This is exactly why Zed often suggests that we go back and write comments around seemingly easy exercises. It can feel tedious, but I still do it.

In related news, “Very” Early Bird tickets for PyTennessee opened today and I got one! $50 for an earlybird ticket for a two-day conference is a steal, especially if I can find a couch to sleep on for the weekend. Hopefully I’ll be pretty far along in my journey by next February and will learn a lot from the experience.

Today is October first and in the spirit of my favorite month of the year I want to share one of my favorite recipes: chole (chana) masala. It’s one I love to make for crowds and dinner parties because it always pleases. I also enjoy preparing it for sick friends as it keeps exceptionally well, actually improving the longer it sits in the fridge (up to a point!). It is a variation of the recipe shared here. Let me know if you have any questions.Chana masalaIngredients:

  • 1/4 cup coconut oil (unrefined works)
  • 1 very large yellow onion, thinly sliced (sweet onions also work — I’ve had great luck with giant vidalias)
  • 1 small jalapeno or other hot pepper, seeded and minced (wear gloves!)
  • 1 1/2 heaping tablespoons minced fresh garlic
  • 1 heaping tablespoon minced fresh ginger
  • 1/4 – 1/3 cup finely chopped fresh cilantro (omit if averse)
  • 2 28 oz cans diced organic tomatoes in juice, undrained (no basil or seasonings added)
  • 1/2 teaspoons salt (add more to taste if your tomatoes are unsalted, but most are salted)
  • 3 1/2 – 4 cups cooked chickpeas
  • 1 tablespoon agave nectar
  • Juice of one small lime or 2 teaspoons tamarind concentrate
  • 1/2 cup coconut cream
  • Post Punk Kitchen spice blend
    • 1 tablespoon plus 1 teaspoon ground cumin
    • 1 tablespoon ground coriander
    • 1 teaspoon ground turmeric
    • 1/2 teaspoon fennel seeds, chopped
    • 1/2 teaspoon cardamom
    • 1/4 teaspoon cinnamon
    • 1/8 teaspoon ground cloves
    • 1/4 teaspoon ground cayenne (add more or less to taste)

Please note that in this and any recipe, it’s incredibly important to use fresh, fragrant spices for the best-possible dish. I’ll cover proper storage of spices in a later post, but for now: if your spices smell like sawdust, they’ll probably taste that way, too. Toss ’em and invest in something new.

Instructions:

Preheat one of your largest pans or pots over medium heat. I use a large, heavy-bottomed pan because I have one and it helps the tomatoes cook down faster, but if you don’t, you can use a large pot.

Make your spice blend by combining spices in a bowl and whisking with a fork or small whisk.

When the pan is hot, add coconut oil. Allow it to warm. Add the onion (you should hear it sizzle) and cook about ten minutes. Onion will become soft and golden, and depending on how hot your pan is, may brown some. You may elect to leave the onions mostly undisturbed, or give them a good toss every few minutes or so. Just don’t burn them!

After about ten minutes, add the hot pepper, garlic, and ginger all at once, and stir constantly for about 30 seconds to a minute. Add the spice blend and stir constantly for about another minute. Make sure the onion-pepper-garlic-ginger mixture is thoroughly coated.

Add the tomatoes and mix well, scraping the bottom of the pan to get all that sauteed goodness. Add salt and chickpeas. Cover the pan and raise heat to medium-high, but once it has reached a strong simmer, uncover. Reduce heat to medium. Allow to simmer enthusiastically for about twenty minutes, stirring every few minutes or so. Be mindful of the heat – you don’t want anything to burn. The point is to get the tomatoes to cook down so that the dish is thick and saucy rather than watery.

Once it’s reached a good consistency, stir in about a half a cup of coconut cream. You can use more. Creaminess is wonderfulness.

Adding my secret ingredient - the coconut cream!

Adding my secret ingredient – the coconut cream!

chanamasala3

Adding the tamarind

Add the lime or tamarind and agave nectar. Taste for seasonings and adjust as necessary. Add cilantro if using. Remove from heat and allow to sit for about ten minutes.
Serve!

Thanks to Isa and Terry at the Post Punk Kitchen for inspiring me with this recipe.

0

LPTHW: Exercise 1: A good first program and roasting vegetables

Howdy folks. Today I’m writing to you from Dr. Bombay’s Underwater Tea Party (real name) where I just finished Exercise 1: A good first program.

To be honest, this is the fourth time I’ve worked through this exercise. I started in early 2012 and have had several stops and starts with LPTHW since. (But this time it’s stickin’.)

I was surprised when I actually made some mistakes! I realised I’d used the GUI to create a “Learn-Python” folder in my home directory but I hadn’t cd’ed into it before trying to run my “good first program”. But when I tried to cd into it, it wouldn’t let me! A-ha: “cd learn-python” won’t work, because Python is case-sensitive. Little slip-ups, but important to the learning process.

ex1py

It feels weird to call ex1.py a “program” because all I’m doing is printing some lines. In the extra credit Zed has us comment out our working using #, but that’s really the extent of this chapter. I feel like a “program” should do something more exciting.

While we’re here, let’s chat about something similarly basic in the kitchen: roasting vegetables.* It’s easy and something you should feel empowered to do.

01_roastedeggplant

You can roast eggplant.

01_roastedpeppers

You can roast peppers.

01_mapleroasted

You can even roast whole pans of stuff.

There are too many blog posts on the internet about roasting red peppers, heads of garlic, acorn squash, etc. I don’t intend to add to the bulk by making a simple concept fussy, or insisting that every vegetable deserves its own special treatment. Sure, you can do that if you’d like — and sometimes it’s appropriate. (Feel free to Google if you’re curious.) But for your average just-got-home-from-work, wanna-be-doing-something-else, need-vegetables eater, what I am about to explain is more than sufficient.

Roasting is not complicated. The most you’ll have to think about, really, is how long you want to roast a given food. By this I mean: tender foods (like eggplant, summer squash, very young fennel) will need less roasting time. Firmer foods (potatoes, winter squashes) will need a little more. If you’re just roasting a sheet pan of acorn squash, it’s going to take somewhat longer than a sheet of asparagus. Acorn squash takes about an hour. Asparagus takes about 25 minutes.

But here’s the thing! You can actually roast firmer foods with more tender ones, as long as you cut them into smaller pieces so they’ll cook faster. See the example above: those are fairly small potato pieces (they’re also an especially tender variety, hence my choice).

Cutting pieces of food uniformly is a basic cooking skill you should practice. Chefs don’t just do it because it looks good. It also ensures that your food cooks more evenly.

So! Roasting!

Here’s how I do it:

  1. Prep vegetables. (Clean, core, chop uniformly, etc.)
  2. Pre-heat oven to 400 degrees Fahrenheit.
  3. Gather all vegetables in your largest bowl. Drizzle generously with olive oil and sprinkle with salt and pepper.
  4. Spread the vegetables out onto a heavy-duty rimmed baking sheet (jellyroll pan).
    1. Note: you will not need to grease your pan because you have already generous coated all of the veggies with oil.
  5. Roast for 35 – 45 minutes total, removing them from the oven every 15 minutes to stir (or in the case of large pieces, turn over).
    1. I recommend using the thinnest metal spatula you have to scrape up all the roasty goodness.
    2. Larger pieces (like halves of peppers) can be negotiated with tongs.
    3. Tender foods will take less time.
    4. Firmer foods will take more. Adjust as needed.

I like to play around with a combination of olive oil, soy sauce, maple syrup, and dijon mustard for potato-and-onion-based roasts. Try it!

*We are not having a conversation about how eggplants and peppers are technically fruits.

0

Free libraries and free software

Today’s post doesn’t have anything to do with Learn Python The Hard Way, but I thought it was worth sharing all the same.

It’s about my love for free software.

Today I got an itch to make some beats. I’ve been spending a lot of time in the gym lately and I’m never without my MDR-V6s. I know, I know — it’s terribly uncool to be dancing on the treadmill with giant headphones on. (But they’re the best, y’all!) My gym mix is ever-changing and all about energy. This morning I enjoyed some new Trust, old Skrillex, way too much Nikki Minaj, a few songs I heard on RuPaul’s Drag Race, and always, my girl Speakerfoxxx. I love a heavy, driving beat to keep my moving forward and push myself to the limit. (Go girl, go girl, go girl.)

So, I thought — why not try my hand at it? It’s probably really hard, I thought — but I might have some fun.

Because I’m all about free software, all I had to do was open up my terminal and issue one simple command:

get-itOh, apt-get. You are so very delightful.

In about a minute, it appeared. My heart fluttered and my face broke out into an irrepressible smile. At the risk of sounding silly, I shared on Twitter: “gosh, i love free software. sudo apt-get install x gives me the same feeling as walking into the library as a kid: the world is mine.”

LMMS

But that was exactly it. When I was a kid, the library was my favorite place. I exhausted the school’s collection and begged for trips to local branches. I was a little local library connoisseur, calling them by their full, proper names, and even noting the county system — yes, I was a nerdy kid!

I craved the promise that the library held: the world could be mine. Who knows what I might find in the stacks, between the pages?

That feeling rushed me when I installed LMMS. And it could have been anything. The other night, I couldn’t figure out how to do something, so I googled and found that I needed to install something very small. Though it didn’t work and I had to make another choice, it felt profoundly empowering to be able to even try. It’s thrilling to know that the work of some of the world’s brightest, most generous and principled developers is always out there for me to discover when I need it, just like the great works of literature that lined the shelves of my childhood libraries.

And LMMS? Well, I’m now the proud creator of a fifteen-second track that is actually pretty enjoyable, perfect for a first attempt.

Thanks, FOSS.

1

Bash for beginners / most common conversions

Recently I took off to Chattanooga to spend the day drinking coffee, playing cards, eating good food, and… learning Bash? Yep. Turns out craft coffeehouse Brash provides the perfect backdrop for making flashcards (henceforward known as bashcards) and gettin’ down the basics.

bashatbrash
Featuring Android: Netrunner. I slay as Andromeda.

bashcards
a few of the bashcards

I’d already worked through the Command Line Crash Course‘s terminal-based exercises, but I wanted some practice drilling. Thankfully my beau was willing on the long, slow drive back from Chattanooga. I didn’t have too much trouble, since I recognized many of the terms from my first attempt at Learning Python the Hard Way. Only xargs made me go argh! I definitely feel like I have a good enough handle on the basics to move on to the first chapter, so I’ll cover it in my next post.

For today’s cooking tip, I want to share a few cooking conversions and measurements that I use all the time. Like Bash above, just memorizing these will make your life so much easier. Say you’re making a salad dressing and it calls for all kinds of “tablespoon this”, “teaspoon that”… and you want to triple the recipe for a party. Are you really gonna stand there and carefully measure out 9 tablespoons of sticky tahini, when you could just do a generous 1/2 cup* and call it a day?

Here are the measurements I use all the time:

Dash = 1/16 of a teaspoon. This is nothin’. This like a dustin’. When you see a dash of something, consider that it’s basically an optional ingredient. …Just kidding. …sorta.

Pinch = 1/8 of a teaspoon. This is quite a bit more than nothin’, so don’t discount it. It’s okay to literally pinch a bit of the spice and toss it in (to your mise en place, remember?), but if you want to measure it out, that’s okay too. (If you’re working with cayenne or another pungent spice you might actually prefer to measure it.)

One teaspoon = 1/3 of a tablespoon.
Two teaspoons = 2/3s of a tablespoon.
Three teaspoons = 1 tablespoon.

It’s so helpful to know the above when you’re reading a recipe that says “5 teaspoons” (seriously, I hate that). If you see “5 teaspoons”, just think 1 tablespoon plus 2 teaspoons (or, if you’ve got some experience at eyeballing, a 2/3s-filled tablespoon).

Two tablespoons = 1/8 cup.
Four tablespoons = 1/4 cup.
Eight tablespoons = 1/2 cup.
Sixteen tablespoons = 1 cup.

When I see a recipe that calls for four tablespoons I know they need an editor. Quarter cup y’all!

Your 1/3 cup measure go missing? No big deal. Just measure out 1/4 cup plus 4 teaspoons (or 1/4 cup plus 1 tablespoon plus 1 teaspoon). Note: the internet believes that 1/3 cup equals five tablespoons. This is not true, but it works for most purposes. 1/3 cup is actually slightly over five tablespoons (hence the +1 tsp above).

Doubling a soup? Memorize these:

Pint = two cups
Quart = two pints (4 cups)
Gallon = four quarts (16 cups)

So there you have it: a beginner’s guide to some of the most common and helpful cooking conversions. While I highly recommend that you memorize the above, you can use Google if necessary. Just specify what you’re looking to convert (i.e., “How many ounces in a pint”) and Google will help you out.

googleGoogling: not just for learning Python!

*technically 9 tablespoons = 1/2 cup + 1 tablespoon, but I’ve been in this gig long enough that I’m lazy. I do “scant” for just under a given amount and “generous” for just over.

6

Exercise zero: the setup. Mise en place.

“All you need is an editor, a Terminal, and Python.”

So goes LPTHW’s exercise zero. Zed walks his reader through identifying a basic text editor, locating the terminal, and installing Python. He also explains the importance of being willing to Google for answers.

getting_started

According to Mr. Shaw, I must have a thing for control since I’m a Linux advocate. (Where’s my huge beard tho??) Kidding aside, Linux — and Free and open source software (FOSS) more generally — just makes sense to me, and I’ve been using it since I started grad school in 2007. Astonishingly, our computer labs all ran Ubuntu!

It took a few days to get the hang of the slightly different look, but I was hooked from the start. I resonated deeply with what I understood to be the guiding principles of FOSS. Why not use software developed by people who are excited to build it, who are daily dreaming up and making improvements, and who are guided by a communitarian ethos? And once you’ve made something, why not share it with others for mutual benefit?

But that’s an aside for another post — and something I care about so much is certain to get its own post! Back to exercise zero.

Text editor, terminal, Python. Pretty straightforward, eh? NOT SO FAST. When I picked up LPTHW two years ago, he didn’t have the nifty “Command Line Crash Course” as Appendix A. Instead, you just noodled your way through basic bash in the course of the lessons. I’m going to spend today and tomorrow working my way through it before proceeding to the next lesson. I have a feeling that much of it will be familiar.

How about in the kitchen? What do you need to get started there?

miseenplace

The most important concept I can share today is that of mise en place. Pronounced “MEEZ ahn plahs”, it’s a French term that means “put in place”, and it’s about all the preparation you do before food is put to the flame.

Ever wonder how high-end kitchens can turn out complex, artful dishes in a reasonable amount of time? It’s because they can spend anywhere from four to six hours before dinner service prepping ingredients and their workstations before a skillet ever hits the gas.

Mise en place is a philosophy so dear to some that they get tattooed with the phrase. It’s a way of life, a dictum that means get all your stuff out so you can get your food out. It’s slowing down so you can speed up.

Home cooks are well served by putting mise en place into practice. Next time you’re hungry, try to follow these guidelines:

    • Start with a clean kitchen. Remove distractions.
    • Read the recipe thoroughly.
    • As you’re reading, make mental note of technique, kitchen tools, and ingredients used.
    • Check your pantry for ingredients.
    • Check in with yourself to make sure you know how to do what the recipe is asking. If you don’t know what “blanching” means, follow Zed’s advice above and google it. If you don’t have a chinois and it seems essential, google alternatives or consider picking another recipe. No shame in that!
    • Check your pantry and fridge for all ingredients.
    • Prep all ingredients: chop, dice, mince, measure, etc.
    • Read the recipe one more time.
    • Take a deep breath. You got this. It’s time to cook!

Vocab re-cap

  • bash: the command line interface that I’m learning the basics of with the help of Appendix A
  • FOSS: free and open-source software: users have the freedom to run, copy, distribute, study, change and improve the software (from What Is Free Software?). I use Ubuntu, a popular Linux distribution. I don’t really like the Unity desktop environment so I usually use xfce. Once upon a time I also used Kubuntu and KDE.
  • mise en place: French: “put in place”. Loosely, an instruction to gather and prepare the ingredients and tools needing for cooking.
  • Python: the programming language I’m learning and writing
  • terminal: where I run the code
  • text editor: where I write the code

Now I’m curious: what’s the coding equivalent of getting a mise en place tattoo? What command do you live by?

And for the cooks: can you remember a time you didn’t employ mise en place, and what were the consequences? Most recently I started making lemony cornmeal-blueberry muffins and realised I was out of plain cornmeal. In a pinch I tried tamale flour. Surprisingly, it worked!

2

Getting started

At Coding with Knives, I’ll be working my way through Learn Python the Hard Way‘s fifty-two chapters. I’ll share my struggles and victories with the exercises, as well as other tips I pick up along the way.

But I’ll be honest: I’m nervous.

I haven’t taught myself how to do anything since, um… well…

since I learned how to cook!

Over the past fifteen years I’ve been honing my skill daily. I’ve worked in and out of restaurants, from managing staff and advising on recipe creation, to cooking for families throughout Atlanta as a personal chef. These days I can roll up into your kitchen and make a gourmet meal out of whatever you have on hand, but it wasn’t always that way. It’s taken the commitment of daily practice, an insatiable curiosity, and even some risk to get to where I am. The best part is: I’m still learning!

I think the same might be true with learning how to program. Sure, you could take a bootcamp (and I’ll admit, some of them sound awesome) and learn a language in three months, but most of the folks I know who are successful have been curious about programming their entire lives. It seems to be as much a daily practice for your average FOSS* contributor as it is for a skilled cook. You’re always learning, growing, making new connections, challenging yourself.

Whether you’re here to cheer me on, pick up some cooking tips, or just because you’re curious: welcome. I’m glad you’re here.

So, what are your burning cooking questions?

I reached out to some of my smart friends and heard back the following:

  • How to time a meal when preparing multiple dishes
  • How to cook rice
  • Sauteing onion and garlic together such that the garlic doesn’t burn up.
  • Storing vegetables (What can go in the fridge? What shouldn’t go in the fridge? What should be wrapped in towels, etc.)
  • Making tofu taste good
  • Cleaning mushrooms
  • Roasting vs. Baking vs. Fire-roasting vs. Broiling etc. (basically, what do all these terms mean?)
  • Cooking with different oils
  • Anything to do with baking. Baking scares me.
  • Cooking with dried beans (which need to be soaked, quick-soak techniques, slow-cooker techniques)
  • Spices.  When would I use one over the other?  Which ones “go” together?  I want to rosemary in everything, but not everything wants rosemary.  How long can I keep spices?  Ditto makeup. 😉
  • Buying organic.  When does it really matter?  (I kinda know this, but I think it’s good to cover.)
  • When would doubling a recipe be a problem?  Or is it ever?  Especially with regard to crockpot cooking.
  • RICE! There are so many kinds. Also, there are lots of kinds of beans. When should I use which?

I’m looking forward to covering all of the above and more in the days to come. But for now, what are YOUR burning questions? +1 to any of the above?

*That’s the acronym for “free and open source software”, which we’ll chat about, too!