Skip to main content

Beyond the Basic Stuff

·4 mins

This is another book review. It’s Beyond the Basic Stuff with Python: Best Practices for Writing Clean Code, by Python popularizer Al Sweigart. (The book is free on his site! Thanks, Al!)

As a mostly self-taught programmer, I stumble on the “missing middle” a lot. You try to learn more about programming, and tell me what you find. There are a thousand online and print tutorials out there. And it feels like the majority just want to tell you how to get started.

Let me show you this amazing programming language! Uh, here is how it does a “for” loop. Okay. Go conquer the world, you crazy kids!

You gotta try our amazing new framework! Here’s how you set up all the dependencies. Look, you just wrote a counter component! You are a programmer! Go make a Facebook!

And this traditional advice—stop reading, start coding—can be very rewarding. Maybe we really do understand something best by doing it, implementing it, by ourselves. Just like writing, completing something gets you both satisfaction and a solid stepping stone to the next thing. And like writing, we can look back and wince at older work, but it’s comforting to notice what improvements now seem obvious.

That is how I got to an intermediate level of Python know-how: finding tasks which would give me an excuse to use Python, Django, Flask, Pandas, FastAPI. Getting comfortable with Python as a tool, even if my work’s day-to-day tasks were more about managing releases and infrastructure.

I imagine the traditional way to develop as a programmer is in the workplace (or in an open source project), where you have lots of opportunity to fix and create working, used code. Even more importantly, that sort of setting allows for mentoring, code-review, and exposure to other ideas.

If you are trying to teach yourself, though, there’s a frustrating sense of plateau. You try to set interesting goals for your own programming and dig in to documentation and do it for your own toolkit.

But try to find some clear instruction and examples of how it’s all done at a higher level—not just hobbyist or handy-dandy local hack—and it feels like the resources quickly dry up.

You go looking for that elusive next level, and academia presents you with algorithm theory like the Corman Book, or fundamentals which border or esoterica to a workman coder, like Petzold’s Code: The Hidden Language of Hardware and Software. No doubt great stuff, but this generalist computer science instruction (vs. software development) leaves me a bit at sea. Where are my practical yet not basic books?

So that’s what Sweigart has set out to do. He wants to give us a grand tour, not into programming concepts or computer science depths, but into sharp Python code. I am always on the lookout for books like these, which contain not just hows but whys, which get past the “here’s how you do the same things you do in any language or environment,” and demonstrate their useful idioms and strengths.

This book does that. Sweigart demonstrates giving default values to dictionaries. He compares the enumerate function to the range function, contrasting clarity and speed. (He tends to start with simple recommendations, then go deeper into their ramifications.) He give code examples of what makes list comprehensions readable, and what’s going on behind the scenes with those “dunder functions.” He points out common pitfalls, where many a Python programmer has stubbed a toe.

He also spends 45 pages talking about git and about Big O notation. I get the feeling he’s really written this for self-taught or inexperienced programmers, worried we’ll embarrass ourselves around the water cooler. (By which I mean, in the the Slack.) Don’t let those CS degree people shame you for not knowing jargon!

It’s hard to tell what this book’s effect will be on me until I’ve written more Python. I know that next time I go back over projects, look for a bug in open source code, or start something fresh, I will glance over this book again and see how it guides me. I’m very interested in how all this advice and example change my practice!

Next steps toward Python skill-up:

  • Luciano Ramalho’s Fluent Python, which seems more complex and in-depth and lots of fun

  • Reading code of Python projects like cloud-init and bits of OpenStack

  • Getting lured by the dulcet tones of Golang or Rust

Please let me know if you have any suggestions of great Intermediate → Advanced Software Development books or tutorials.

I would especially love recommendations of great open source code to read and learn from.

Let me know, folks!