Archive for August, 2009

Coming from a .NET background and having applied SOLID principles to software development, I was surprised by the lack of inversion of control containers for Python.

The few discussions I read online implied that Python doesn’t need an IoC framework because it is a dynamically typed language.  Dynamically typed languages eliminate the need to use interfaces, they do not do away with the need for inversion of control.

IoC is used to decouple components of an application, remove direct dependencies so that replacing a component will not have a side effects on the rest of the system.  As Dave Thomas explains

a DI application is written as a set of loosely coupled components. These components contain no knitting code: nothing in the application code itself is responsible, for example, for making sure that the necessary objects somehow get an instance of the database connection. Instead, the components all run in a container. This container is given a description of the knitting to be done (typically using an XML file). The container then instantiates objects and sets them into components that need them

I’m new to the language and there maybe a more “pythonic” way to handle inversion of control than using a container. Here is small and contrived example of inversion of control using Pinsor, a IoC container in Python. Those coming from a .NET or Java background will find Pinsor easy to use, but slightly lacking in features.

With most of the paperwork done I’ve started to make use of my free time in Toronto.  In an effort to improve my Python programming I implemented a cummulative sum estimation based change point detection algorithm in Pyton based on an article by Dr. Wayne A. Taylor.  The changepoint project is available on Google code– all comments are apprecaited.

Search