Simon Willison’s Weblog

Subscribe
Atom feed for python

1,161 posts tagged “python”

The Python programming language.

2008

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

Whitespace Sensitivity. Amusingly, Ruby is actually far more sensitive about whitespace than Python is.

# 1st July 2008, 2:50 pm / ruby, python, armin-ronacher, whitespace

Graphite. Real-time graphing package for server monitoring, similar to RRDTool. Created by the team at Orbitz, using Django and ExtJS for the frontend and Cairo to generate the graphs.

# 28th June 2008, 11:53 pm / graphite, cairo, orbitz, rrdtool, monitoring, graphing, django, python, extjs

How-to: Full-text search in Google App Engine. Use search.SearchableModel instead of db.Model—it’s pretty rough at the moment which is probably why it’s still undocumented.

# 27th June 2008, 8:25 am / googleappengine, appengine, full-text-search, python, search

CookBookNewFormsFieldOrdering. Handy tip—change the order of fields in a Django newforms instance by over-riding form.fields.keyOrder (since fields is a SortedDict).

# 27th June 2008, 1:02 am / newforms, django, python, tip

Django snippets: Command to dump data as a python script. Extremely useful—dumps the data for an application as an executable Python script which will re-import it in to another database without any risk of colliding with existing IDs, sorting out foreign keys along the way.

# 24th June 2008, 12:07 pm / django, python, import, django-snippets

The basics of creating a tumblelog with Django (via) Ryan Berg suggests having a StreamItem model that links uses a GenericForeignKey to link to other content types, then using signals to cause a StreamItem to be created for every other model type. I should switch to doing that on this blog: at the moment I have to query three separate tables to build the tumblelog part which results in messy code for ordering and pagination.

# 24th June 2008, 11:09 am / ryan-berg, django, python, tumblelog, genericforeignkey, contenttypes

Tailor. “Tailor is a tool to migrate or replicate changesets between ArX, Bazaar, Bazaar-NG, CVS, Codeville, Darcs, Git, Mercurial, Monotone, Subversion and Tla repositories.”—written in Python.

# 24th June 2008, 9:59 am / python, tailor, bazaar, cvs, codeville, dvcs, darcs, git, mercurial, monotone, subversion, tla, version-control

jsontime. Nat and I threw this together this morning—it runs on Google App Engine and exposes Python’s pytz timezone library over JSONP.

# 21st June 2008, 7:07 pm / jsontime, json, javascript, api, projects, python, pytz, appengine

PortingDjangoTo3k. Martin von Loewis has started assembling a patch. His write-up illustrates some key differences between Python 2.X and Python 3—it looks like Django’s unicode handling is going to require the most work.

# 19th June 2008, 5:53 pm / python3k, python, martin-von-loewis, django, unicode

Reddit release their codebase. Under the same Common Public Attribution License used by Facebook for their recent source release.

# 18th June 2008, 2:32 pm / open-source, reddit, python, cpal

New foundation for Django. Django now has its own nonprofit software foundation (courtesy of a bunch of tough paperwork by Jacob Kaplan-Moss), and fittingly the Lawrence-Journal World get the exclusive.

# 17th June 2008, 5:16 pm / ljworld, django, python, jacob-kaplan-moss, dsf

Spicing Up Embedded JavaScript. John Resig collects the various ways in which a JavaScript interpreter can be hosted by Python, PHP, Perl, Ruby and Java. There are full JS implementations in PHP, Perl and Java; Ruby and Python both have modules that use an embedded SpiderMonkey.

# 15th June 2008, 11:32 am / javascript, john-resig, spidermonkey, python, java, php, perl, ruby, embedding

DebugFooter middleware with Pygments sql syntax highlighting. Andreas Marr has enhanced my Django DebugFooter middleware with proper syntax highlighting for the logged SQL.

# 14th June 2008, 10:04 am / django, middleware, andreas-marr, debugfooter, python

Censoring the Internet at Paraguay. The state owned telecommunication company DNS hijacked the opposition party’s domain to point at a porn site during the election back in April. Maybe we don’t want a django.py vanity domain after all...

# 13th June 2008, 3:24 pm / paraguay, django, python, censorship, dns

RFC: Django 1.0 roadmap and timeline. Jacob’s proposed target is “early September” for the final 1.0 release.

# 12th June 2008, 10:34 am / django, python, jacob-kaplan-moss

Shortcutting render_to_response. I tend to use a simple wrapper function, but the other options described here are worth exploring. This is why I’m so keen on Django’s “take a request object, return a response object” philosophy—it makes it trivial to extend the framework in the direction you want.

# 10th June 2008, 11:49 am / django, request, response, python

Python + Hadoop = Flying Circus Elephant. Last.fm have released Dumbo, a Python module that lets you easily write Hadoop map/reduce tasks using Python and generators.

# 31st May 2008, 2:14 pm / hadoop, python, generators, lastfm, dumbo, mapreduce

modswgi: Debugging Techniques. mod_wsgi is excellent software, and the documentation is equally superb. I used these instructions recently to run the Python debugger inside a running instance of Apache, which helped my track down some import errors that weren’t occurring with Django’s development server.

# 25th May 2008, 1:34 pm / modwsgi, django, python, debugging, pdb, wsgi

AOP aspect of JavaScript with Dojo. Fantastic post—concisely explains Aspect Oriented Programming, then shows how Dojo’s dojox.lang.aspect brings AOP to JavaScript, including some really useful built-in aspects for logging, profiling and more. Aspects are like Python decorators on steroids.

# 18th May 2008, 10:45 am / aspects, aop, javascript, decorators, python, dojo, dojox, eugenelazutkin

Using Git as a versioned data store in Python. gitshelve supports the same interface as Python’s built-in shelve module but stores things to a versioned Git repository instead of just a pickled dictionary. I’ve been casually wondering what a Git-powered CMS would look like.

# 15th May 2008, 3:25 pm / git, cms, gitshelve, python

Python with a modular IDE (Vim). Great tips—I’d use these if I wasn’t still scarred from the time vim encrypted my file instead of saving it because I had caps lock on by mistake.

# 12th May 2008, 7:09 am / capslock, vim, python, ide