Archive for the ‘Python’ Category

Django vs Pylons

This is an attempt to make a non-biased comparison between Django and Pylons. I did a brief comparison of the two at work since we needed a web framework for our new project.
We are making a web application that will serve as a frontend to a bank database. The application is going to allow bank [...]

Maybe exceptions are not so awesome after all

Maybe I got a bit rusty on my 1 month vacation, but today I ran into a simple problem that I spent 2 hours solving. I Am working on a website made in Django and I decided to make some changes to the model in one of the apps in the project. I currently have [...]

A recursive django template tag

Here is my attempt to create a "silver bullet" tag for printing tree structures with the Django templating language. It's far from a silver bullet, tho, but it can do basic stuff:
It's a modification of the standard "for" tag and i have kept the counter, counter0, first and last variables, only this time they are [...]

Python 2.6, Leopard 10.5.6 and psycopg 2.0.10

Psycopg2 is the postgreSQL adapter for Django. If you are trying to set it up on Mac OSX (using the supplied setup.py script) you may run into an error saying
File "setup.py", line 219, in finalize_options
NameError: global name 'w' is not defined

This is a simple thing to fix: open the setup.py file coming with psycopg2 and [...]

Maze Drawer

This piece of python code is going to draw some mazes in a .PNG format. It's a side-product of the solution to the Google Code Jam practice problem B called "Always turn left". The script takes the input data sets and draws the mazes described with every test case. You will need Python with Python [...]

Some problem solving and how it’s easier with python

There's a project I work on that required me to make an import utility for a CRM. The import should get a comma separated values file of clients and information about clients, and save it to the database. The database is split across several tables, so in the `clients` table I normally don't keep the [...]

Fun with pythonchallenge.com

This site is ultra cool. I should be studying for my exams, but this is bloody addictive: http://pythonchallenge.com
Anyway, I made it to the 10th level where you can see a bull saying: len(a[30]) = ? so obviously i need to calculate the length of the 31st member of a. Now, we don't know what a [...]

Configuring Django to work with your OSX X (Leopard) apache

I hope that I finally got it right, since I can see the admin interface and the media files are being served by the same development server as the site. The machine is an Intel MacBook running OS X 10.5.6 and python 2.6.1 I suggest reading the official Django documentation on setting it [...]

Install mod_python on Mac OS X

This is not my article, i copied it from here for safe keeping.
First, you?ll need to grab the source to mod_python. I recommend version 3.3.1, which is what I?ve worked with. Then, you?ll need to unpack it:
$ tar xvzf mod_python-3.3.1.tar
$ cd mod_python-3.3.1
$ ./configure --with-apxs=/usr/sbin/apxs
At that point, the configuration script will spit out a lot of [...]