Simon Willison’s Weblog

Subscribe
Atom feed for python

1,069 items tagged “python”

The Python programming language.

2008

UnicodeDictWriter—write unicode strings out to Excel compatible CSV files using Python. Stuart Langridge and I spent quite a while this morning battling with Excel. The magic combination for storing unicode text in a CSV file such that Excel correctly reads it is UTF-16, a byte order mark and tab delimiters rather than commas.

# 20th August 2008, 12:19 pm / excel, csv, internationalisation, i18n, byteordermark, python, stuart-langridge, unicode, unicodedictwriter, utf16

minidetector. Neat piece of Django middleware that adds a “mobile = True” attribute to the request object if the request’s user-agent matches a list of strings of known low-power browsers in mobiles, PDAs or game consoles.

# 15th August 2008, 8:21 am / minidetector, middleware, django, python, mobile

This Week in Django. After 33 episodes Django’s usually-weekly podcast finally has its own website.

# 14th August 2008, 2:57 pm / thisweekindjango, django, python, podcasts

Keyczar (via) New open source cryptography toolkit from Google, designed to get algorithm selection, key rotation and versioning right so you don’t have to. Java and Python versions are available; the Python version depends on PyCrypto.

# 13th August 2008, 1:20 pm / pycrypto, python, google, encryption, keyrotation, ben-laurie, java, keyczar

Django snippets: RequestFactory. I’ve been wanting this for ages; when I finally got around to writing it it turned out to only be a dozen or so lines of code. Makes it easy to create mock request objects in Django, which you can then use for testing view functions directly (bypassing the current test client mechanism which requires views to be assigned to a URLconf before they can be tested).

# 12th August 2008, 12:40 pm / django, testing, requestfactory, code, python, httprequest

Changeset 8266—Added ModelAdmin.save_model() and ModelAdmin.save_formset() methods. One of those small changes that opens up enormous possibilities—it’s now incredibly easy to customise exactly how a model is saved in the Django admin interface by over-riding the save_model method.

# 10th August 2008, 1:17 pm / django, admin, python

GeoDjango Documentation. Merged to Django trunk a few hours ago. The tutorial isn’t there yet, but the rest of the docs are worth exploring.

# 5th August 2008, 11:06 pm / geodjango, documentation, django, python

My Universal Feed Parser was conceived as a weapon against what I considered the gravest error of XML: draconian error handling. Recently, someone asked me to implement a switch that makes it not fall back on lax parsing in the case of an XML wellformedness error. I said no, not because it would be difficult to implement, but because that defeats its entire reason for being.

Mark Pilgrim

# 5th August 2008, 10:52 pm / xml, mark-pilgrim, universalfeedparser, feeds, draconian, wellformedness, python

simple-thrift-queue (via) Phillip Pearson’s surprisingly concise in-memory message queue written in Python using Facebook’s Thrift library (which is similar to Protocol Buffers, but was open sourced much earlier on). Handles 4,000 requests per second on a laptop.

# 4th August 2008, 12:27 pm / messaging, phillip-pearson, python, facebook, thrift, protocolbuffers, message-queues

PDFMiner. Useful looking PDF parsing library in Python—can produce an XML representation of the text and style information in a PDF document.

# 3rd August 2008, 3:29 pm / pdf, python, xml, screenscraping, pdfminer

Changeset 8162. “Implemented a secure password reset form that uses a token and prompts user for new password”—also sneaks base36 encoding and decoding in to Django.

# 31st July 2008, 10:54 pm / django, python, lukeplant, changeset, security, base36, passwords

Super User Conditional Page Exception Reporting. The name is almost as long as the code snippet: this serves Django’s debug page to logged in super-users, falling back to the default 500 template for everyone else.

# 31st July 2008, 9:06 pm / django, python, debugging, exceptions, middleware

Spawning + Django. The latest version of Spawning (a fast Python web server built on top of the Eventlet non-blocking coroutine networking library) can run Django applications out of the box, using threads and processes to work around the blocking nature of the ORM’s database drivers. Eric Florenzano reports better performance than Apache and mod_wsgi, and is now hosting his site on it.

# 31st July 2008, 10:56 am / eric-florenzano, django, python, comet, eventlet, spawning

DjangoCon & Django 1.0 updates. DjangoCon tickets will be released in two batches of 100. The first set will be available at 12 noon UTC on Thursday July 31st; the second set will be released at 6pm UTC on Friday August 1st.

# 30th July 2008, 10:25 am / tickets, djangocon, events, django, python

Extra fields on many-to-many relationships (via) Checked in just over an hour ago, Django now lets you specify a custom “through” table for a ManyToManyField. Great work by Eric Florenzano.

# 29th July 2008, 1:58 pm / manytomany, eric-florenzano, django, python, through

FLOSS Weekly 34: Django. Randal Schwartz interviewed Jacob Kaplan-Moss at OSCON for the consistently excellent FLOSS Weekly podcast.

# 27th July 2008, 9:47 am / flossweekly, open-source, randalschwartz, jacob-kaplan-moss, django, python, podcasts

Dojango version 0.3 released. A reusable Django application that provides Dojo, helper functions (dojo.data integration) and tools for switching between Dojo versions.

# 24th July 2008, 12:47 am / dojango, dojo, django, python, javascript

Python BoF and Django Drinkup (via) At OSCON? Come along to the Jax Bar tonight (Tuesday 22nd) from 7pm to 10pm to hang out with fellow Pythoneers and Djangonaughts.

# 22nd July 2008, 6:48 pm / python, django, oscon, social, bof

Replacing Django’s Template Language With Jinja2. Part of Will Larson’s series on taking advantage of Django’s loose coupling.

# 22nd July 2008, 5:18 pm / django, loosecoupling, jinja, python, will-larson

Django 1.0 alpha release notes. The big features are newforms-admin, unicode everywhere, the queryset-refactor ORM improvements and auto-escaping in templates.

# 22nd July 2008, 6:04 am / orm, django, alpha, python, newformsadmin, unicode, querysetrefactor, autoescaping

Django 1.0 alpha released! Not meant for production use, but a pretty solid preview of what’s coming in 1.0 proper. The beta is scheduled for August 5th.

# 22nd July 2008, 6:01 am / django, alpha, python

DjangoCon 2008. The official DjangoCon site is up, along with a mostly complete schedule.

# 20th July 2008, 8:49 pm / djangocon, django, python

Jinja2 Final aka Jinjavitus Released. The Jinja template engine now has auto-escaping as an optional feature, disabled by default. Worth considering as an almost drop-in replacement for Django’s template language if features such as macros and compilation to Python code appeal to you.

# 19th July 2008, 11:52 pm / jinja, python, autoescaping, django

Simple Top-Down Parsing in Python. Eye-opening tutorial on building a recursive descent parser for Python, in Python that uses top-down operator precedence.

# 19th July 2008, 11:37 pm / python, effbot, fredrik-lundh, parsing, compilers, recursivedescent

DjangoCon 2008. Venue: Gooleplex, San Francisco Bay Area. Dates: 6th and 7th Sept. Official post will be on djangoproject.com soon.

Robert Lofthouse

# 13th July 2008, 4:50 pm / robert-lofthouse, djangocon, django, python, events, google, googleplex, san-francisco

ftputil. Python’s built-in ftplib is ridiculously low level, requiring you to send RETR commands and even assemble downloaded chunks yourself using a callback. ftputil looks like a really solid high-level interface to that module with file-like objects and plenty of convenient methods.

# 9th July 2008, 10:51 am / ftp, python, ftputil, ftplib

Protocol Buffers: Google’s Data Interchange Format. Open sourced today. Highly efficient binary protocol for storing and transmitting structured data between C++, Java and Python. Uses a .proto file describing the data structure which is compiled to classes in those languages for serializing and deserializing. 3-10 times smaller and 20-100 times faster than XML.

# 8th July 2008, 8:20 am / c-plus-plus, google, idf, java, open-source, protocolbuffers, python, xml

Django Unit Tests and Transactions. If you’re using a transactional database engine (MySQL with InnoDB, Postgres or SQLite) you can speed things up by running each of your unit tests inside a transaction and rolling back in tearDown().

# 7th July 2008, 2:14 pm / unittesting, unittest, python, django, transactions, innodb, mysql, sqlite, postgresql

OSM routing, A*, cycle-filtered, python (via) A python library for finding routes using OpenStreetMap data.

# 5th July 2008, 3:13 pm / python, routing, osm, mapping, openstreetmap

Running C and Python Code on The Web. Adobe are working on a toolchain to compile C code to target the Tamarin VM in Flash. This will allow existing C code (from CPython to Quake) to execute in a safe sandbox in the browser.

# 4th July 2008, 8:26 am / browser, c, python, quake, adobe, tamarin, flash