Home » Python (page 5)


MockupDB: Testing The MongoDB C Driver With Python

This is the third article in my series on “black pipe” testing. The series describes how to test networked code, like a MongoDB driver. Such code has two distinct public surfaces: one is its API, and the other is its communication over the network. Treating it as a black box tests just one surface, the API. To test both, we ...

Read More »

Testing PyMongo As A Black Pipe

This is the second article in my six-part series on “black pipe” testing. PyMongo, the official Python client for MongoDB, is a great example of a connected application that can’t be fully tested as a black box. It has two ends that take inputs and provide outputs: one is its public API, the methods find and insert_one and so on. ...

Read More »

Neo4j: Loading JSON documents with Cypher

One of the most commonly asked questions I get asked is how to load JSON documents into Neo4j and although Cypher doesn’t have a ‘LOAD JSON’ command we can still get JSON data into the graph. Michael shows how to do this from various languages in this blog post and I recently wanted to load a JSON document that I ...

Read More »

Python: Extracting Excel spreadsheet into CSV files

I’ve been playing around with the Road Safety open data set and the download comes with several CSV files and an excel spreadsheet containing the legend. There are 45 sheets in total and each of them looks like this: I wanted to create a CSV file for each sheet so that I can import the data set into Neo4j using ...

Read More »

Python: Converting WordPress posts in CSV format

Over the weekend I wanted to look into the WordPress data behind this blog (very meta!) and wanted to get the data in CSV format so I could do some analysis in R. I found a couple of WordPress CSV plugins but unfortunately I couldn’t get any of them to work and ended up working with the raw XML data ...

Read More »

The Clash of Template and Delegate Patterns

Back in my delegate decorator article, I mentioned some weaknesses of the delegate pattern as a substitute to inheritance. The decorator solved one of those problems, but the other is still a problem. The problem comes when using something akin to the template pattern.             The Problem For example, if you have this class: class ...

Read More »

Strategy Pattern Sans Objects and Functions

As many of my readers will likely know, my favorite design pattern is the Decorator Pattern, but I don’t think I’ve mentioned what my second favorite pattern is. This is understandable, as I have a difficult enough time picking favorites usually, let alone second favorites. Well, my second favorite is sort of a toss up between the Factory Pattern and ...

Read More »

Python Decorator for Simplifying Delegate Pattern

Recently, I posted about how you can use composition instead of inheritance, and in that article, I mentioned the Delegate Pattern. As a quick description, the pattern has you inherit from the parent interface (or, in Python, you can just implement the protocol), but all the methods either redirect to calling the method on an injected implementation of interface/protocol, possibly ...

Read More »

Want to take your WEB dev skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • PHP Programming Cookbook
  • jQuery Programming Cookbook
  • Bootstrap Programming Cookbook
  • Building WEB Apps with Node.js
  • CSS Programming Cookbook
  • HTML5 Programming Cookbook
  • AngularJS Programming Cookbook