Everything I Know About Python...

The personal blog of author, speaker, tutor, and professional software engineer Jeff Knupp

Python Dictionaries

Aside: one thing I dislike about the official Python documentation is that only a small percentage of entries have example code. We should change that...)

One of the keys to becoming a better Python programmer is to have a solid grasp of Python's built-in data structures. Using the structured format below, today you'll learn what a dict is, when to use it, and see example code of all of its member functions. I have some other data structures in the works, so this may turn into a little series.

Read on →


Flask and SQLAlchemy Magic

For my first "real" post after my extended leave, I wanted to cover something fun (well, fun if you like writing libraries with Flask and SQLAlchemy...). In one of my projects at work recently, I was tasked with turning a client-facing Flask app that I had written into a framework/library that made creating new "sub-applications" as easy as possible. One pattern that had worked well in the original app was the use of Flask-SQLAlchemy, both for interacting with a new set of database models and in connecting to existing databases owned by other teams. One existing database, in particular, was heavily used by the app and would likely be used a good deal by any "sub-apps" created on the framework.

The database in question was essentially our company's "main" database, with about 100 tables (each with thousands or millions of records). This is a common, and somewhat frustrating situation when writing internal libraries: you know clients are going to need to use some resource, but you're not exactly sure how or what parts of it. How do you create an interface to that? With SQLAlchemy specifically, does that mean each sub-project will need to describe all of the tables it needs to use from the "main" database, leading to repeated, boilerplate code? Of course not! All it takes is a little magic.

Read on →


Sorry for the Silence. I'm Back!

I'm Sorry/I'm Back

My second daughter was born on October 27th. I'll be honest: I haven't read email sent to jeff@jeffknupp.com in almost three months. In fact, I haven't done anything besides my day job, sleeping, and spending time with my girls for the past three months. Throw in a medical condition (that has been resolved) and you can see why the past few months have been difficult for me. I know that I'm making excuses, but I wanted to add some context about my silence.

Thanks to my incredible wife and daughters, I now have the chance to be active online once again. For those of you who emailed me and didn't receive a response, I'm terribly sorry. I promise I will get to every single one in the weeks ahead. If you asked for a free copy of the book, you'll get one. It's going to take me a bit of time to catch up with everything, but it will get done.

Read on →



Info on Free Tutoring Session For Women In STEM

In a previous post I announced that I would be permanently making by book, Writing Idiomatic Python, free for women in STEM. In addition, they would be entitled to two free hours of tutoring. The response was overwhelming. While everyone who emailed me got a free copy of the book, it just wasn't physically possible for me to tutor all who requested it. While I'd love to tutor everyone one-on-one, it's simply not possible.

Instead, I've decided to hold "office hours" (or a "group tutoring session") where participants can ask Python questions (or email them to me ahead of time) and I'll answer them, live. The first session will be this Saturday, September 13th, at 10:00 AM EST. If all goes well, additional sessions will follow. It will be held on Google Hangouts (unless someone has a better free suggestion), and all women (and those identifying as women) in STEM are free to join.

Email me your questions!

If you have a question that requires a bit of background or explanation, please feel free to email me with the subject "Office Hours" and describe your question. I'll do my best to answer all questions I receive ahead of time.

See you soon

I'm really looking forward to this and hoping it goes well. If you're down, I'll see you in a week!

Read on →