This is the first post of a sporadic series where we will dive into the weeds of more complex Python code review samples. I will take (slightly modified) real-world code samples, explain some common mistakes that have been made, and how we can improve things. Let’s jump right in!
Tag: Programming
The Thing about Mutable Default Arguments in Python
Yesterday I stumbled across some code that contained a mistake a lot of Python developers get wrong. Let’s see why and how to fix it.
Converting MySQL Table Data to a Graphml File
I recently found myself in the situation where I was given access to a huge MySQL database that contained network traffic flows and IDS signature match data. As I work a lot with graph-based approaches, I needed to convert the table’s flow data into a graphml file for later visualization and analysis with scripts I have already written. Now without further ado here’s the code…
The “Pythonic” GOTO
Nope, I’m not going to join the goto war. Even though it’s shunned among developers, there are still some situations where it makes sense. A good friend of mine with a background in C recently came to me with a very simple problem that still made him scratch his head when he tried to express it in Python. The problem broke down to comparing three lists to find an element that meets a special criterion. His basic naive concept looked something like this in pseudo-code…