Posts tagged: PYTHON

Understanding tuples vs. lists in Python

Python has two seemingly similar sequence types, tuples and lists.

The difference between the two that people notice right away, besides literal syntax (parentheses vs. square brackets), is that tuples are immutable and lists are mutable. Unfortunately, because this distinction is strictly enforced by the Python runtime, some other more interesting differences in application tend to get overshadowed.

One common summary of these more interesting, if subtle, differences is that tuples are heterogeneous and lists are homogeneous. In other words:

World's ugliest Django app

OK, this is an ugly hack. But also (possibly) cool if you’re into ugly hacks.

I’ve written a small Python script that is a fully functional, self-contained, self-starting Django application. You don’t need to put it on your PYTHONPATH or set DJANGO_SETTINGS_MODULE. You don’t need a web server. It even creates some dummy content for you. I call it jngo.py – it’s somewhat compressed.

The only prerequisites are a Unix-like operating system (i.e. I couldn’t tell you how to make it work on Windows), SQLite and a working install of Django trunk. It is fully “Works on My Machine” certified.

A little something I've been working on

The latest This Week in Django podcast, out today, has an interview with me. I really enjoyed talking with Michael and Brian, and hope I didn’t come off sounding too dorky (or long-winded – I haven’t yet listened to the show, but based on the timestamps in the show notes I could probably use an edit!). I think they do a very good job with the show, and in fact I think that the structure Michael came up with – Tracking Trunk, Branching & Merging, Community Catchup, Tip of the Week – is one that other open source projects would do well to emulate in their news missives.

Visualizing trends in the bug-tracker

At work I manage projects with Trac. It’s great. We have about ten different projects, including websites and internal web apps, with most of the code in a central Subversion repository hooked up to Trac so that it’s easy to see what got changed when (and why!).

But rather than bore you with Trac evangelism I’ll share a goofy hack I built to get a basic visualization of the ticket load in Trac over time.

Python was apparently 2007's Language of the Year

I just learned that TIOBE (who maintain a popular but controversial listing of programming language popularity statistics) declared Python the “language of 2007”. Most notably, it is now (according to TIOBE) more popular than Perl:

Last month Python surpassed Perl for the first time in history, which is an indication that Python has become the “de facto” glue language at system level. It is especially beloved by system administrators and build managers. Chances are high that Python’s star will rise further in 2008, thanks to the upcoming release of Python 3.

Python 3.0a1 on OS X

First alpha release of Python 3.0 (formerly Python3000) is out today. And it even works! Gotta do something about that executable name, though…

$ ./python.exe 
Python 3.0a1 (py3k, Aug 31 2007, 15:11:11) 
[GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

(Download, What’s New)

OSCON 2007, Day 4

Keynote speakers

Ben Fry talked about Processing (I missed this part, but fellow attendees who hadn’t heard of the language before we very excited and impressed.)

Bill Hilf from Microsoft notes that they’re moving to some OSI-approved licenses.

Rickard Falkvinge from Sweden’s Pirate Party spoke about their attempt to reform intellectual property law. In their first election, they got only 0.63% of the vote, buy this placed them in the top 10 parties in their first election – a record for a first-year political party. I don’t think that intellectual property regulation is a broad enough base for a political party, but the fact that they’re getting so much interest is very telling. After Falkvinge noted that political contributions are not regulated in his country, one audience member ran up and handed him cash!