Python sorted, itemgetter, stdin

I find it interesting how implementing a simple algorithm can teach you so many new things.

I was recently implementing the fractional knapsack problem

The interesting was – during implementation I got to learn some interesting things about Python.




Python Break : Improve Your Python

I came across this very interesting series of blog posts. The authos (Jeff Knupp) discusses some nuances in Python


There are a bunch of “Improve Your Python” articles in that blog. Check them out.


Python Class Attributes

I recently came across this interesting article on class attributes v/s instance attributes in Python.




Factory Pattern in Python

I recently used the factory Pattern in Python.

It was a little surprising to me comparing typical usage of this pattern in C# v/s Python.

In particular, in C# you’s typically have an Interface defining the methods and then provide an implementation of these methods in the concrete classes.

In Python, there is no interface – In the example above I embed a static  method in the base  to select the appropriate derived class.