There are two exciting Python Coursera classes coming up and I have signed up for both of them! What, you say? It’s a bad idea to do two so close together, especially when there’s some overlap? Perhaps… but I hope you’ll read on and let me know what you think. There’s a delicious soup recipe hiding at the bottom of this post, if that’s any incentive!
University of Michigan’s “Programming for Everybody (Python)” is a beginner-oriented course that starts on Monday, February 2 and lasts 11 weeks, with an expected 2-4 hours of work per week. We’ll be starting with variables and expressions and finishing with tuples and regular expressions. I don’t even know what tuples are! But I’m excited to learn.
The cool thing about this class is that all of the material is freely available here. Check it out if you’re curious to see what we’ll be covering!
I signed up for this course because it came highly recommended by Anna and because I resonate with the professor’s big goal of making programming truly for everybody. Since I’m interested in bringing other women into the fold as part of my learning journey, I hope to pick up some pedagogical skills and open-source resources in addition to a better understanding of Python.
Yet, because the course seems so low-impact, I decided I needed to pick up another Coursera:
Rice’s “An Introduction to Interactive Programming in Python (Part 1)” is all about learning Python while making games. Though they champion it, I’m a little dubious about the browser-based programming environment that they use. They said it makes developing interactive applications in Python simple, but I’m nervous because I’ve never used anything other than a text editor and a terminal to write and run code. We’ll see how it goes!
This course is much shorter: just five weeks. The weekly workload is considerably more, however: 7 – 10 hours. That translates, on the upper end, to two hours a day, five days a week! Add in another half an hour or so per day for the other class, and I’m in for a busy few weeks. It may not work at all, but why not try? What’s the worst that could happen – I have to un-enroll from one and take it later? That’s a risk worth taking.
I’ve got a lot of other stuff going on right now, but I hope to use Coursera to help me stay focused. Strangely, sometimes when I have the most stuff going on, it helps to throw more onto the pile so I can clarify my desires. The “Survey of Music Technology” class I took in the fall brought order and accomplishment to some of my busiest months of 2014 (October & November). It gave me something to look forward to, concrete goals to meet, and interesting projects to make and have evaluated by my peers. Plus, I learned how to use a Digital Audio Workstation (DAW*) and got some experience with the EarSketch Python API!
My hope with each of these is that I will make more of an effort to involve myself in the Coursera learning community that builds up around these classes by participating in the message boards. I was kind of a lone wolf in my music tech class and perhaps didn’t get as much out of it as I could have in that regard.
Looking forward to getting started soon!
For today’s cooking lesson, I’d like to share a very simple soup recipe that I wrote last week when it was cold for a couple of days. Since a lot of my friends are snowed in, perhaps with some root vegetables hanging around on their shelves, I thought a creamy, warming soup would be just the ticket! This soup takes about a half an hour, making it a great way to get dinner on the table fast.
Coconut Curried Butternut Squash and Sweet Potato Soup with Caramelized Shallots**
- 1 – 2 tablespoons coconut oil
- 2 cups shallots, finely chopped
- Several cloves garlic, minced, or about 1 generous tablespoon
- Large knob of ginger, minced, or about 1 generous tablespoon
- 1 generous tablespoon fragrant, good-quality curry powder
- 6 cups of prepared stock, vegetarian chicken-style if you can get it, or just vegetable
- 1 medium butternut squash, peeled and chopped. About four cups.
- 5 – 6 medium-sized carrots, peeled and chopped. About 1 1/2 cups.
- 1 giant sweet potato or two medium-sized, peeled and chopped. About 3 – 3 1/2 cups.
- One 15 oz can of coconut milk
- Juice of half a lemon
- Optional: if you like it spicy, finely mince one small chipotle (from canned/packed in adobo)
Immersion blender or regular blender
Saute shallots in coconut oil until soft and caramelized, over medium heat, minimum six minutes.
Add garlic and ginger and cook til fragrant, about one minute. Add curry powder and stir to coat shallots, garlic, and ginger, about thirty seconds.
Pour in prepared broth and scrape the bottom of the pan to incorporate all that good toasted curry powder and caramelized shallots. Add butternut squash, carrots, sweet potatoes. Bring heat to high in order to bring to a boil, then reduce and allow vegetables to simmer, partially covered, about twenty minutes or until tender.
Once vegetables are tender, carefully use an immersion blender to puree. If using a regular blender, allow soup to cool til you’re able to handle it safely, then pour it into blender and puree in batches if necessary.
Once soup is fully pureed, add can of coconut milk and stir to incorporate. You may also choose to use a small can of pure coconut cream if you don’t want to add as much liquid. Allow to cook about two minutes over medium-low heat.
Add lemon and taste for salt. If you didn’t use a salty broth, you may need to add it. If using optional minced chipotle, add now. Allow to sit about ten minutes before serving so that the flavors can meld somewhat. Tastes even better the next day, and keeps a week in the fridge!
Some images from the process:
*The class uses Reaper, but since DAWs are pretty similar, I was able to apply what I learned to my DAW-of-choice LMMS!
**long title! feel free to call it something else!
Thanks so much for the tremendous show of support in response to my last post! I took a risk and shared something tender, and you demonstrated that I really ought to be doing that more often. I feel humbled by the response and grateful for my community.
This weekend I reflected on the role of encouragement in the learning process, especially as I consider what will be helpful to share with my mixed audience of absolute novices and experienced developers at PyTN. For the latter group, I cannot overstate the importance of reaching out to learners in whatever way you feel comfortable: whether that’s a RT, a blog comment, an invitation to coffee, or just letting them know you’re there if you need anything. It’s certainly made a world of difference to me.
And yet, when you reach a certain level of expertise, it can be easy to take your skill for granted, and hard to see the utility in reaching out. You lose sight of the awesomeness of your work because it’s just what you do every day. I reckoned with this Thursday when I taught a cooking class on something very basic and easy to me, but exciting and even intimidating to others: seitan. It was gratifying to consider the learner’s perspective as I prepared my curriculum. While teaching, I was reminded that I have a pretty special skill, one worth sharing, and from that recognition grew a sense of responsibility.
And so, as I receive encouragement from a community of developers to share my learning journey, I hope folks with more experience will feel empowered to reach out to those of us getting started. Don’t let your years of grinding it out cloud your belief in your own awesomeness and power to make a difference. That tweet or comment may be exactly what we need!
Encouragement has taken many forms in my learning journey, from receiving support to speak at PyTN, to an email that changed the course of my project, to my brilliant friend Kyle always being there to answer questions, and more. I feel both supported and held accountable, and capable of much more than I thought.
For today’s cooking lesson, I want you to head over to my friend Sarah’s blog and read about the cooking class I taught on Thursday on seitan. Seitan is a versatile, centuries-old protein developed in China and is used in all manner of savory dishes as a vegetarian powerhouse where beef, chicken, or pork might otherwise be used. Sarah does a terrific job covering the material and is adorable and hilarious. Recipes are below, after a few images of how you might use it. Enjoy!
Chicken-style seitan, boiled method
- 1 cup vital wheat gluten
- 1/4 cup chickpea flour
- 1/4 cup nutritional yeast
- a couple of big pinches of sage
- 1 cup flavorful broth
- 2 tablespoons soy sace
- 1 tablespoon olive oil
- 2 tablespoons garlic, pressed or Microplaned
Thoroughly whisk together the dry ingredients: vital wheat gluten through sage. In a measuring cup, whisk the wet ingredients: broth through garlic. Add the wet to the dry and combine thoroughly until a dough is formed. On a floured surface, knead the dough to develop the gluten, about 3 minutes. Tear into three equal pieces and drop into a highly-seasoned broth of your choice (about six cups of whatever vegetable broth you have on hand). Bring broth to a boil and reduce to a simmer, simmering about 45 minutes.
Allow to cool. Chop into small pieces and pan-fry, add to recipes, etc. Store in cooking broth in the fridge, up to a few days. Freezes well.
Italian sausage style seitan, steamed method
- Two cups vital wheat gluten
- 1/3 cup nutritional yeast
- 1/4 cup chickpea flour
- 2 tablespoons onion powder
- 2 teaspoons fennel seeds, chopped
- several dashes of freshly-ground black pepper
- 1 teaspoon chili flakes (or fewer), depending on how spicy you like it)
- 1 teaspoon ground smoked paprika
- 1 teaspoon oregano
- 1 1/2 teaspoons salt
- 2 cups cold flavorful broth
- 3 tbsp neutral oil (canola, vegetable, or olive)
- 2 tbsp soy sauce
- 2 cloves garlic, pressed or Microplaned
Thoroughly whisk together the dry ingredients, vital wheat gluten through salt. In a measuring cup, whisk the wet ingredients: broth through garlic. Add the wet to the dry and combine thorough until a dough is formed. Knead it a bit to make sure everything is incorporated, and then grab a small handful. Place in the center of a square of tin foil and fold like a tootsie roll. (Thanks to Julie Hasson for this method!) Fold gently, leaving room for the seitan to expand (think tamales, if you’ve had practice with those). Place in a steamer basket and steam for 45 minutes.
Once cool enough to handle, chop and pan-fry, add to recipes, etc. Remove all from foil wrappings and store in the fridge up to a few days. Freezes well.
Seriously though, check Sarah’s blog: she explains the process very nicely.
Hi again! If you’ve been following along, you might have noticed a little gap in my posts. That’s because I’ve spent the last ten or so days doing a lot of behind-the-scenes work for PyTennesssee. Self-reflection, writing, organizing my work, and yes, studying! LPTHW’s exercise 22 – where I left off – is all about review; exercise 23 is reading code; exercises 24 and 25 are more practice. All of these lead up to 26: a test!
Notably, I’ve been thinking about an incredibly thoughtful email I received from Anna of DjangoGirls. If you don’t know her, get familiar: she does amazing work and will be presenting at PyTennessee. A fellow autodidact from a non-technical background, she’s been following my work at Coding with Knives and reached out to share some wisdom about the process.
First of all, she recommended a ton of new Python-learning resources, from Coursera’s Programming for Everybody (enrolled!) to Lynn Root’s advanced exercises at newcoder.io (one day!). Her list opened my eyes to the breadth of opportunities out there.
Second, she shared meaningfully about her own journey, especially with regard to the frustrating moments and how she navigated them. This was in response to my own expressed frustration on Twitter. As a learner, there’s something encouraging about hearing folks I perceive as experts share the times when they didn’t feel quite so boss.
Third and finally, she expressed some concern about the pace I’d been keeping as I worked through the LPTHW exercises. She sensed that I was really pushing myself hard, and she was absolutely right. I took her email in the spirit intended: supportive, curious, open-hearted, and it became a much-needed jumping-off point for thinking about my process.
So I’ve been thinking critically about why I am doing this, and asking myself if my current learning path is serving me. Should I keep doing LPTHW exclusively, when there are so many great resources out there? Is this blog just a place to post screenshots of exercises like homework assignments turned into no one in particular?
No. While there are lots of great things about LPTHW, and I intend to follow it to completion, I’ve decided that basing this blog entirely around completing one book’s exercises is simply not enough. I started Coding with Knives to share thoughts about where I am in my Python learning journey, pairing reflections with recipes and cooking tips from my years of kitchen experience. Anna’s message helped me get back in touch with this original intention.
Further, I’ve put a lot of pressure on myself to complete the LPTHW exercises as quickly as possible in advance of PyTennessee. This pressure comes from a place of feeling inadequate, or like I don’t have any right to be standing alongside the experts at PyTN. You can sense that in my response to the conference organizer when he reached out to me about speaking a few months ago:
I (could) discuss resources that were helpful to me…strategies I used to hold myself accountable, and any difficulties I encountered along the way. It won’t, however, be the kind of talk where I necessarily teach the audience something groundbreaking about Python. Do you still think it’s worth submitting?
Sit with that last line for a second. Despite the fact that he reached out to me because he thought I was doing something cool and worth sharing, I was still covered in doubt.
What you are proposing in the email is exactly what I’d like to see. Share your real experiences and your path. A good talk is more about relating and sharing than “groundbreaking”.
Anna’s message reminded me what I want Coding with Knives to be: a place where I share my real experiences and my path, rather than a place where I feel like I have to post screenshots of my terminal & text editor (though I’ll totally still do that, because I think it can be fun!).
Why? Ultimately, my desire is to inspire other women to code; especially women who never imagined they could. As someone who grew up on a small family farm in rural Georgia, earned a BA in philosophy & history and a MA in theology, and spent a good part of my twenties running restaurants or cooking for people, I’m entirely familiar with that lack of confidence. But it won’t prevent me from acquiring the skills I need to start building, and contributing to, projects I love – especially with inspiration and support from women like Anna!
So what’s next?
Second, I’ve enrolled in the Coursera class “Programming for Everybody (Python)” beginning February 2. I had a great experience with another Coursera class (Introduction to Music Technology) and am looking forward to this one!
Third, I’m reading “Think Python: Think Like A Computer Scientist” because I’ve wanted to for some time. It comes highly recommended and I can already tell why: he has a gift for making difficult concepts clear and accessible.
Fourth, I’m watching Jessica McKellar’s “Hands-on introduction to Python for beginning programmers” from PyCon 2014. A great suggestion from Anna.
Fifth, I’ll use this space more conversationally as I share what I’m learning. Concepts, yes, but also current events and non-Python experience. For example, a couple of months ago I learned some git basics and managed my first pull request on Github, but I didn’t really know how to talk about it here. The outstanding article I read yesterday on Model View Culture about code schools is another worthy topic, especially since I’ve considered them.
In summary, I’m stepping beyond my previous notions of what my Python path must look like and am opening myself to the rich and resonant variety of resources out there. To that end, I thought of a decent cooking analogy.
When you first start cooking seriously for yourself, you have to use recipes. Maybe you’ve got that friend who insists they never use them, who’s all “oh, I don’t follow anyone else’s instructions, I just throw some things in a pan and season to my liking.” Sure. Thing is, if that’s all you ever do, your range will be quite limited – restricted, essentially, to throwing shit into pans.
To bake, or try an unfamiliar cuisine, or work with new tools, you have to follow someone else’s instructions. And I’ve found that I learn most effectively when I source a variety of perspectives. Like LPTHW launching my Python journey, one cookbook’s pancake recipe might get brunch on the table. But let yourself read six recipes, comparing and contrasting them, and see what happens. My guess is that taking a holistic look at a basic process told several different ways will make it easier to grasp and more likely that you’ll get creative, sooner.
And that’s ultimately the goal, right? To get creative sooner: to start building things and contributing to FOSS projects I care about. And in so doing, perhaps I’ll inspire other women to do the same.
PS: This post is full of admissions that were hard to make because, as anyone with perfectionist tendencies might understand, it involves acknowledging that what I’d originally planned wasn’t working. It can be hard to switch gears when doing so comes with the requisite guilt for making an “imperfect” plan, compounded by self-doubt that the new one might now work either! But growth here means moving forward and attempting to apply that same flexibility, dynamism, and curiosity that I developed in the kitchen to learning to code. Cheers to the journey!
This week I really picked up speed with Learn Python the Hard Way. A quick review of my progress:
Monday, January 5: Exercises 7, 8, 9, and 10. Instructions on prepping kale.
Tuesday, January 6: Exercises 11 & 12, and a kale recipe.
Wednesday, January 7: Exercises 13 & 14, and instructions on how to prep tofu.
Thursday, January 8: Exercises 15, 16, & 17. Attended PyATL meetup that night!
Friday, January 9: Studied exercises 18, 19, and 20. Drafted first half of cooking lesson.
Saturday, January 10: Completed exercise 21 and posted 18, 19, 20, 21, and a significant cooking lesson.
Now I’ve moved on to exercise 22, in which I’m supposed to review all previous chapters (0 – 21, and the Command Line Crash Course) and identify all symbols used. I’m doing this on paper, taking notes as I review the previous exercises.
I’ve been taking notes on paper through the exercises, as I find it’s a good way to force myself to be concise and really put what I’m doing into my own words. I also sometimes draft phrases for my posts on paper, though more frequently in text files. I’ve also have pages and pages of notes from the several times I attempted LPTHW in the past.
Tonight, however, I’m taking myself out for the first time since New Year’s Eve! I’ve been working incredibly hard all week: really applying myself and devoting all available free time to my Python lessons. Tomorrow, I’m attending another meet-up. So, at least for tonight, I am allowing myself a bit of fun: Atu and Dpat at Basement ATL with a new friend. Adios for now!
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.
Today’s exercises have to do with files: reading, writing, and manipulating them.
Exercise 15: Reading files
Exercise 15 was pretty approachable. Essentially, I wrote a little script that opens a text file and prints it. I wasn’t content to use Zed’s meaningless sentences, so I grabbed some Mary Wollstonecraft Shelley to class the joint up a bit.
In the study drills, I alternately deleted lines where I used raw_input and *only* used raw_input to see what happens in either case. I also started Python and tried use open as directed, but I wasn’t able to get it work, even with my amazing friend Kyle’s help. I’m probably missing something really obvious. He gave me some great tips that I plan to try tomorrow.
Something I think Zed does really well is remind us how helpful it can be to write comments. Comments help others read your code, but as a learner, it’s also helpful for me to write them so that I know what’s going on… even it sometimes it gets kinda long, as in the case of exercise 15:
Still, worth it.
Exercise 16: Reading and writing files
Exercise 16 was pretty straightforward as well. Zed introduces a list of commands to remember:
Exercise 17: More files
Exercise 17’s study drill questions have to do with making the code cleaner, shorter, and easier to read. When Zed said that he could reduce the entire script to one line of code, I balked… and for the first time, I got frustrated. Indignant, even! Though I could definitely see ways to trim it down, I didn’t see the utility in reducing it to one line. I shared this with a new friend at the PyAtl meetup tonight and he concurred. Just because you can write something in a long, complicated manner, it doesn’t necessarily mean you’re doing yourself (or your reader) any favors.
Likewise, when I asked my friend Kyle about it, he helpfully advised that when writing code, consider the balancing act between lines of code and doing too many things on one line. Too many lines of code roughly equates to maintenance cost, he explained; but doing too many things on one line makes that line very difficult to understand. While it might be possible to write most of the script on one line, it might not be considered good style… or very friendly to future readers.
Ultimately, Kyle said, “it’s an aesthetic thing with no right or wrong answer. Just takes time and experience to develop your own.” I plan to keep his wise words in mind moving forward.
That’s it for tonight – gasp! No cooking lesson. I’ll make up for it with an extra-good one next go ’round…which may or may not involve something beer-battered and fried. (Let’s just go ahead and agree that it will. YES!)