You are currently browsing articles tagged python.

cover for "introduction to tornado"

The book that I co-wrote with Mike Dory and Brendan Berg for O’Reilly has been released! It’s a gentle introduction to Tornado, a web application framework for Python. Unwittingly included in the book are several of my (previously unpublished) remixes of the last stanza of Frost’s “The Road Not Taken”—along with, of course, the code you need to make your own.  Order a copy from Amazon or directly from O’Reilly.

Tags: , , ,

Hello Word!
An evening of poetry, performance, and experimental text design from NYU/ITP’s Reading and Writing Electronic Text

Friday, May 6th 2011
721 Broadway, New York, NY
Ground floor (Common room)

Over the course of Spring semester, sixteen NYU students have engaged in intense electro-textual experiments: composing, mangling, generating and remixing electronic text using the Python programming language. For one night only, these students will gather to present and perform their experiments to the general public.

Some examples of projects that may make an appearance at the event: movie dialogue remixed in real time; dynamic newspaper blackout poetry; an endless exquisite corpse from Twitter search results; infinite generative creation myths; and much more.

Reading and Writing Electronic Text is a course offered at NYU’s Interactive
Telecommunication Program. ( The course is an introduction to both the Python programming language and contemporary techniques in electronic literature. See the syllabus and examples of student work here:

Poster design by Sofy Yuditskaya and Martin Bravo. Download a full-size version here.

Tags: , , ,

Last Baby Standing

Last Baby Standing is a game/sim/toy for Facebook, made during last weekend’s Global Game Jam. The game generates statistics for your Facebook friends, then lets you “mate” any two together, producing statistics and a unique biography for each “child.” The game tied for first place in the “Wild Card” category in NYU Game Center’s chapter of the jam. I was part of the extremely talented crew that made this game—here’s the GGJ page for the game, which includes full credits. And here’s the Game Center’s write-up of the event, which includes a full list of winners and links to the all of the games.

Oh, and here’s the github repository.

The theme of this year’s jam was “extinction,” which we found a bit difficult to work with. For the first few hours on Friday night, we worked on an abstract puzzle/gambling game based on the definition of “extinction” in psychology. (The initial prototype of that game is still in the repository as We couldn’t figure out how to make that fun, so we searched for alternative ideas; Last Baby Standing is the result. I’m extremely happy with how we were able to corral all of our technical and creative talents to make something interesting and fun that (mostly!) works great.

Things I learned (mostly technical):

  • FQL is a finicky playmate. Queries that work fine for 200 friends time out with 400. (We used LIMIT clauses and ORDER BY RAND() to get around this limitation. I didn’t know FQL even supported those clauses!)
  • Tornado‘s Facebook Graph authentication mixin doesn’t work right out-of-the-box. I needed to make some changes to the example code and also use the version fresh from the repository (rather than the currently released version).
  • If the whole comedy writing thing doesn’t pan out for him, Rob Dubbin has a real future in generative baby biographies.
  • All you need to produce satisfying portmanteaunomastics is about ten lines of Python code and a regular expression.
  • It is possible to get a decent amount of sleep during the Global Game Jam. You just need to feel confident in the talents and time management skills of your teammates.

I hope everyone enjoys the game! Thanks to the NYU Game Center for hosting, and to Matt Parker in particular for keeping everything running smoothly.

Tags: , , , ,

Since the 2011 version of Reading and Writing Electronic Text begins tonight, I thought I would finally post these photos of last year’s performance event. (Photos courtesy master photographer Rob Dubbin.)

Here are some of the final projects that came out of last year’s class:

Stay tuned for updates about this year’s class!

Tags: , ,

“Be a good chance of sticking a fork in my eye. Temptations off so that people with garden implements.”

This is just one of a practically infinite number of new years resolutions that can be generated by my latest project, A Random Resolution for 2011. I collected about 50,000 tweets matching the term “resolution” on December 31st, 2010 and January 1st, 2011, used a simple grep to extract substrings that looked like resolutions, and fed the whole thing into a Markov chain text generator.

I love using Markov chain text generators on a corpus like this because they manage to both highlight the similarities among all items in the corpus (any given string of characters is likely to have occurred more than once in the corpus), while juxtaposing parts of seemingly unrelated items in surprising (and often amusing) ways.

Technical details: I built the application in a few hours using Tornado, an open-source web framework from the FriendFeed team at Facebook. The application is running behind an nginx server on an EC2 micro instance (a product I’ve wanted to try since Amazon released it last year). I’m amazed at how these tools made it quick and easy to throw the whole thing together. The text generator is using n-grams of eight characters; I chose eight because seven or fewer characters produced too many non-words, while nine too frequently reproduced tweets unchanged from the source text.

Tags: , , ,

Last Saturday, Socialbomb held its first Hack Day.

I had two goals for Hack Day: (1) get a PS/2 keyboard talking to an Arduino and (2) make something interesting with Here’s the end result (make sure to click through to the full-screen version for maximum legibility):

Crazy Animal Stories Keyboard from Adam Parrish on Vimeo.

It’s the Unexpected Animal Stories Keyboard, a keyboard which intermittently replaces whatever you’re typing with an Unexpected Animal Story.

It turns out that the part of this project that I thought would be difficult turned out to be easy: getting a PS/2 keyboard talking to an Arduino was a piece of cake. I already had a bunch of mini-din connectors; I just soldered one up to a breadboard, hooked it up to my trusty Arduino Diecimila, put the excellent ps2keypolled library in my libraries folder, plugged in the keyboard and voila: keystrokes gettin’ read.

Here's what the setup looks like

globbiest solders since middle school

I’ve got big plans for the PS/2-to-Arduino data chain, involving a data logging chip and shoes made of keyboards and sledgehammers and/or yogurt. But for Hack Day, I just wanted to whip up something fun. So the next step was to get the keystrokes from the Arduino to my computer, preferably into a sketch. Much to my surprise, Processing’s serial communication libraries worked with without a hitch*, which left me free to write the tiny little generative text toy that you see in the video above.

The biggest unforeseen timesink: I spent a few hours trying to figure out the best way to send ps2keypolled’s 16-bit key codes from the Arduino to the computer, eventually settling on the stupidest possible ad-hoc protocol that could work (and porting a big chunk of C code to Python to translate the key codes to ASCII). See the source code for more details.

Most surprising happy discovery: is amazing. Being able to quickly write the text-munging code in Python while still retaining Processing’s built-in functions and easy-to-use libraries is just… a revelation. For a project that’s just a few weeks old, it feels surprisingly polished. If you’ve got Python and Processing expertise, I recommend you give it a go.

Source code for the whole shebang:

* Okay, there was a single hitch. Apparently, the serial communication library included with Processing (and, therefore, doesn’t support 64-bit Snow Leopard (as documented e.g. here). I was able to get around this without problems by using the -d32 parameter to the java runner, i.e.

$ java -d32 -jar

Tags: , , , , , ,

Poetry in the Post-Now
Bowery Poetry Club
308 Bowery, New York, NY
May 8th, 2010, 12pm-2pm

This is going to be an amazing event. There will be performances, demonstrations, installations and readings from two ITP classes this semester: my Reading and Writing Electronic Text class and Nancy Hechinger’s Writing and Reading Poetry in the Digital Age.

This event is intended to be a showcase for the many text-, language- and poetry-driven projects at ITP, which are sometimes unsuited to the noisy glamor of the regular ITP show (which you should also attend!). I have been overwhelmed by the quality of student projects in both classes, and I’m excited to see them presented and performed.

A sampling of projects from my class: Ramones lyrics interpreted as code, Semaphore Hero, “tagrostics” (procedurally generated acrostics built from word frequency analysis), reading the Ramayana with regular expressions, procedurally generated Vogon poetry, poems composed by weather conditions, self-conversation mangled by Markov chains, physical interfaces for remixing movie subtitles, and more! It may not actually be possible for there to be a better way for you to spend your Saturday afternoon.

Here’s the poster in PDF format. Promotional materials designed by Ted Hayes.

Tags: , , ,

Nick Montfort starts posting about Curveship, his new interactive fiction development system. I’m very eager to see what he’s come up with.

New information to me: Curveship takes the form of a Python framework. Even if this were Curveship’s only innovation, it would still be a huge step forward. Imagine how much easier it’ll be to prototype and author interactive fiction in a well-known, extensible and powerful language like Python, rather than learning a domain-specific language (Inform 6/7, TADS, etc.).

It looks like the framework’s main innovation, though, is that it inserts a layer of indirection between things that happen in the world—”actions”?—and the way those actions are rendered as text.

I’m excited to get my hands on it!

Tags: ,