Entries in category “Python”

Batteries sold separately

Published April 8, 2008

At first glance, Google’s App Engine looks like a great way to build the next big web application; you get access to a massively scalable infrastructure, you get access to a huge existing authentication system, you get baked-in stats, you get all sorts of cool goodies.

Oh, and you get Python, which is a great language for writing web applications, and I’d be remiss if I didn’t take some pleasure in Django ...

Read full entry and comments

Where to find me at PyCon

Published March 12, 2008

My flight arrived in Chicago a while ago, and despite an attempt by the hotel to screw it up, I’m currently sitting in my room enjoying a beer before bed. Here’s my plan for the next few days:

  • Thursday: Working on slides and stuff morning/afternoon, doing the code lab tutorial in the evening.
  • Friday: Definitely hitting up both Django-related talks.
  • Saturday: Hear me speak!
  • Sunday: Probably going to the “What Zope did ...

Read full entry and comments

Managers versus class methods

Published February 25, 2008

In the triumphant return of “James answers questions from the django-users list”, today I’d like to take a few moments to talk something that’s recently become something of a hot topic, spawning not one but two threads, as well as a couple off-list email discussions: what, exactly, is appropriate to put into a method on a custom manager as opposed to, say, a class method, and when and how can you tell?

This ...

Read full entry and comments

On “conceptual integrity”

Published February 11, 2008

Mark Ramm has a nice post this morning talking about Adam Gomaa’s discussion of “conceptual integrity” in Python web frameworks; I think it’s worth a read.

The key point Mark touches on is good documentation: ensuring that people see and understand the overarching structure of the framework is, ultimately, the key to helping people understand how it can help them get their work done. In the case of Django there is an official ...

Read full entry and comments

Making magic

Published December 3, 2007

In yesterday’s article I spent a fair amount of time talking about the word “magic”, specifically in the context of Clarke’s Third Law, which states that

Any sufficiently advanced technology is indistinguishable from magic.

A big part of what I was getting at was that a lot of things which seem to be explicable only by appealing to “magic” are really just cases of technology — sometimes extremely simple technology — being used in a ...

Read full entry and comments

Be careful with your URL patterns

Published October 14, 2007

Tonight in the Django IRC channel, someone stumbled across a seemingly-odd error when trying to use a generic view:

TypeError: object_list() got multiple values for keyword argument 'queryset'

The problem turned out to be the URL pattern which was routing to the generic view. Consider a simple example, as might be found in a weblog application:

from django.conf.urls.defaults import *
from weblog.models import Entry

info_dict = {
    'queryset': Entry.objects.all()
}

urlpatterns = ('',
    (r'^(index ...

Read full entry and comments

PyCon 2007: Web frameworks panel

Published February 23, 2007

(this was liveblogged during the panel, and the only later edits were to correct a couple of typos and add this notice — the content has not been changed)

Titus, the moderator, has welcomed everyone. No blood shed so far. Probably not taking audience questions.

Introduction of the panelists:

  • Spyce: Jonathan Ellis
  • CherryPy: Robert Brewer
  • TurboGears: Kevin Dangoor
  • twisted/Nevow: Duncan McGreggor
  • Zope: Jim Fulton
  • Django: Adrian Holovaty

Titus pauses: “The most interesting thing about Django ...

Read full entry and comments

PyCon 2007: the prelude

Published February 22, 2007

So, I’m in Dallas, eagerly awaiting the beginning of the non-tutorial bits of PyCon 2007; I got here around 4:15PM (after a lovely flight where I was inadvertently bumped to first-class), and already things are rocking; I just got back from dinner and drinks with some folks who are doing really cool stuff with and to Django. Already got some interesting ideas and things to continue fleshing out, and I’ve got another ...

Read full entry and comments

Python framework design

Published February 19, 2007

Lately I’ve found myself being baited into the same old debate over and over and over again, and I’m getting tired of making the same arguments each time. Usually it begins with someone lamenting how Django is anti-community or too inflexible or generally suffering from a raging case of NIH. From there it progresses into people proclaiming how TurboGears or (more often) Pylons is objectively “better” because of how they’re designed, and ...

Read full entry and comments

Programming tips: learn optimization strategies

Published November 5, 2006

Recently I spent a little time talking about the tradeoffs between “concise” code and readable code in Python. Throughout that entry, I was using as an example a simple function which calculates numbers in the Fibonacci sequence; here’s one variation:

def fib(n):
    if n < 2:
        return n
    return fib(n-1) + fib(n-2)

The Fibonacci sequence is a classic example from introductory programming materials, because it teaches recursion, and recursion is an ...

Read full entry and comments

Python tips: don’t be too concise

Published October 28, 2006

There’s an inherent tendency programmers have to take a piece of code and reduce it to the shortest possible form. The holy grail is, of course, cutting something down to a single line of code while still providing the same functionality; reducing a particular piece of code to a “one-liner”, especially if the code is somewhat complex, is sometimes viewed as a measure of a programmer’s intelligence or talent or both, and is ...

Read full entry and comments