Category: Python

  • Intercepting class method invocations using metaclass programming in Python

    In Ruby, objects have a handy method called method_missing which allows one to handle method calls for methods that have not been defined. Most examples out there explain how to implement this in Python using __getattr__, however, none of them (honestly, none) explain how to intercept class method (@classmethod) invocations using __metaclass__. And this is…

  • Geo Proximity Search: The Haversine Equation

    I’m working on a project that requires Geo proximity search. Basically, what I’m doing is plotting a radius around a point on a map, which is defined by the distance between two points on the map given their latitudes and longitudes. To achieve this I’m using the Haversine formula (spherical trigonometry). This equation is important…

  • Java, C, Python and nested loops

    Java has no goto statement, to break or continue multiple-nested loop or switch constructs, Java programmers place labels on loop and switch constructs, and then break out of or continue to the block named by the label. The following example shows how to use java break statement to terminate the labeled loop: public class BreakLabel…

  • Fabric: Simple Pythonic Deployment Tool

    Here’s the thing: you’re developing a server deployed application, it could be a web application but it doesn’t have to be, and you’re probably deploying to more than one server. Even if you just have one server to deploy to, it still get tiresome in the long run to build your project, fire up your…

  • Django 1.0 will be released in early September

    Django has not been updated for a long time. The most current release, 0.96, was released in March 2007. This is a very long time when you look at the roadmap of other frameworks. But guess what, all that is about to change, because Django 1.0 is only two months away! Over the next six…

  • Use a Web-based terminal for remote administration tasks

    Ajaxterm offers a simple solution to those who want to run a terminal over the Web for performing remote administration tasks. Vincent Danen tells you how to get it and configure it for Apache.