The Null Device

Posts matching tags 'python'


Your humble correspondent spent the past three days in beautiful Brutalist Birmingham, at EuroPython. This was my second visit to a Python conference in Birmingham (the first was last year's PyCon), and was just as interesting.

There were some interesting talks there: I found Chris McCormick's talk on RjDj quite interesting, not so much because of the Pythonic bits (a description of a Django-based web app, which is the online side of the app to sidestep Apple's iron grip on software updates), but because of the description of how RjDj works (it's basically Pd, hacked to work as an embedded environment). This has inspired me to look at the Pd sources and see whether it'd be possible to strip the GUI out and make a library, into which one could load a patch and then use that as an audio engine. (It doesn't seem obviously easy, though someone has gotten Pd to work as a browser plugin (with provisos about it being too insecure for anything but a proof of concept).) If one could create a Pd instance, load a patch into it, send events into it and get buffers of samples out of it, it would make a very useful component for everything from softsynths to in-game audio, but I digress.

Other notable talks I saw were Samuele Pedroni's talk about unit testing JavaScript from Python (he showed a Python script that launches a web server, starts some browsers and feeds them pages with the unit tests in iframes, getting the results back to the Python script), Orestis Markou's introduction to PyObjC, and Kevin Noonan's tour of cloud computing technologies accessible from Python (including Amazon Web Services and Google App Engine). At the end, Tommi Virtanen's proposal for Pythonic filesystem APIs to replace the legacy C-style ones (think the os module and such) was inspiring and timely; let's hope the idea gets adopted sooner rather than later.

And then, of course, were the keynotes: none other than Cory Doctorow gave a rousing speech on metaclass design patterns in Django how draconian copyright proposals threaten the right to code and innovate, and veteran computer scientist Sir Tony Hoare (the chap who invented Quicksort) spoke about the differences between science and engineering. They also tried, twice, to get Guido Van Rossum to address the audience via Skype, but that didn't work very well. Which may have had something to do with the flaky WiFi.

There were, of course, a few talks I missed which I would like to have seen; the one on CouchDB, for example, I heard was very good, as was the one about the Psyco Python to C compiler.

I was surprised to find, among the vendor stalls (Google sent two people over from Zürich to give T-shirts to anyone who could solve a puzzle, and Oracle were giving some sort of product away) was one from Ableton, the company which makes music software Live. It turned out that they weren't offering any new Pythonic APIs for mashing up audio (apparently Live has a built-in Python interpreter, though there isn't much one can do with it; they did say that if one bought Max/MSP for Live, one could hack it to one's heart's content); instead, they were just looking for Python developers for web-based applications, and giving away badges and cloth bags.

europython personal python 0


One of the things I enjoy doing is creating electronic music, for which I use a Macintosh laptop, some music software and various plugins. For the past few years, the software which I used has been Apple's Logic Express, to which I switched from Cubase VST when moving from MacOS 9 to OSX. As Logic didn't come with a drum machine program back then, I found myself buying Linplug's RMIV drum machine, which I have over the years used extensively.

RMIV is an excellent and comprehensive drum machine, which contains both analogue-style drum synthesisers and sample playing capabilities, as well as filters and effects. However, it has one downside; when you import sounds into it, it has the annoying tendency of saving those in its own proprietary format (rather than using a standard format such as, say, AIFF or WAV, both of which are good enough for other software including Apple's own samplers).

Recently I have started using Ableton Live, and have found it very impressive. While Live will happily load all my AudioUnit plugins, it also contains its own drum sample player, Drum Rack, which integrates more tightly with it. Drum Rack allows you to drag your favourite samples to various pads and play them. The hitch is that the samples must be in a standard format; if most of your drum samples are in RMIV's .D4T format, then you have a problem. Guess where most of my samples were?

Anyway, not being one to give up easily, I took it upon myself to examine the D4T format, and come up with a way of converting my samples to an open format. Luckily, I had some samples sitting around in both formats; after examining them with hexdump(1) and a Python interpreter, I soon determined that D4T is a fairly simple format, consisting of a short header and the samples in 32-bit float format.

The header turned out to be a bit more work; there were what looked like magic numbers in it, as well as some values roughly proportional to the file size, though bizarrely unrelated to actual sizes. After creating a few oddly-sized AIFF files, importing them into RMIV and examining the imported versions, I determined that RMIV's format used a bizarre way of encoding integers: it would encode them in binary-coded centimal. Which is to say, as a series of bytes, each containing a value from 1 to 99, representing a pair of decimal digits. Why they settled on this peculiar and inefficient encoding, I can only guess; it seems too feeble to be an attempt to thwart reverse engineering.

Anyway, the point of this anecdote is that I have now written a Python script which converts from RMIV's .D4T sample files to AIFF files. (One could change it fairly trivially to make WAV files, though that's left as an exercise to the reader.) The script, named "dermiv", is here.

audio code computer music hacks mac python 2


The source code of the classic urban-planning simulation game, SimCity, has now been released under the GPL. You can find it here. The code is based on the original, UNIX/X11/Tcl/Tk version of SimCity, with a few changes: (a) the game has been renamed to Micropolis (which was its original working title), as "SimCity" is an Electronic Arts trademark for their commercial urban-simulation games, (b) it has been ported to the OLPC XO-1 (the cute green laptop being given to children in developing countries), and (c) everything has been placed in a C++ class and bound to a Python interpreter, making the entire game eminently hackable and extensible in Python. Let a million hacks bloom.

(via alecm, Boing Boing) open-source python simcity society tech videogames 0



JavaScript 1.7, the version used in Firefox 2.0, has a raft of Python-inspired features, including generators and list comprehensions. So now, you can do things like:

function fib() {
  var i = 0, j = 1;
  while (true) {
    yield i;
    [i, j] = [j, i + j];
var evens = [i for (i in range(0, 21)) if (i % 2 == 0)];
And, indeed, bulk assignments, like:
[a, b] = [b, a];
That is, as long as you're not concerned about your code working on non-Mozilla web browsers. (I wonder whether Microsoft, who still have well over 80% of the browser market, will adopt these new features.)

functional programming javascript python tech web 0


The core developers of Python (a rather elegant open-source programming language, in which, incidentally, this website is written) have broken ground on Python 3000, the massive, compatibility-breaking overhaul they intend to give Python, fixing the mistakes, shortcomings and inelegancies in the current version. Here are the things that will change, and here are the things that won't.

It's heartening to see that lambda functions (once slated to be abolished) have been given a reprieve. Otherwise there would have been no concise way of passing anonymous functions as a data type, and instead of being able to do something like (to quote a rather silly example):

greeters = { 
    'english'     : lambda name: "Hello, %s"%name,
    'french'      : lambda name: "Bonjour, %s"%name,
    'australian'  : lambda name: "G'day, %s"%name
one would have to take the long way around, doing something like:
def greet_english(name):    return "Hello, %s"%name
def greet_french(name):     return "Bonjour, %s"%name
def greet_australian(name): return "G'day, %s"%name

greeters = { 'english': greet_english, ... }
And I don't buy the argument that anonymous functions are bad form, and that each chunk of code should have a name that describes what it does. There are many instances where one wants to specify a tiny fragment of code which will fit into a larger mechanism like a small but crucial cog (be it in a function call, a data structure or wherever), without the bureaucratic overhead of giving it a name. Otherwise we may as well be programming in Java or COBOL or some Vogon-designed abomination of a language.

programming python python 3000 2


Civilization IV, the latest in the highly addictive game series, is coming soon, and looks interesting; other than the gameplay, it will be extensively customisable using XML-based data and Python scripting. Ht's probably just as well that there is an organisation such as Civilization Anonymous; I suspect they'll be busy.

(via worldchanging, 433) civilization python videogames xml 3


Nifty Python hack of the day: a C-style switch() construct, implemented without using dictionaries (instead using a class and yield).

(via pythonurl) programming python tech 0


A post on teaching one's children to program in Python:

your_name = raw_input("What's your name? ")
if your_name.lower() == "freja":
  print "You're very stinky,", your_name
  print "You smell lovely, ", your_name

Which sounds like the next generation's equivalent of 10 PRINT "JASON IS ACE!" 20 GOTO 10

education python 3


My latest gift to the world's collection of marginally useful software: x64spriterip, a quick and dirty Python script which pulls sprite images out of Commodore 64 emulator memory dumps and writes them to PGM files. Just in case you ever felt like grabbing some graphics from your favourite childhood computer game for a chat-room avatar or T-shirt logo or somesuch but couldn't be arsed writing the software to do it yourself.

code commodore 64 python 0


Glyph Lefkowitz is not only the developer/prime mover of an impressively elegant Python-based network programming framework, but has also written some nuanced and insightful essays about various topics, including a good argument for extending Python rather than embedding it (i.e., there are many good reasons other than laziness for it), a righteous excoriation of the Ayn Rand Institute's take on the "War on Terrorism", and a very astute attempt at a framework for ethics in software development, which does a good job of unmuddying the waters. Go and read.

glyph lefkowitz programming python twisted 0


TinyP2P, a (not particularly scalable) peer-to-peer file-sharing application in 15 lines of Python. Expected to be printed on T-shirts by cypherpunk dissident types when such programs become illegal, while the rest of the world shrugs, says "those geeks are weird" and gets back to their Trusted Computing pay-per-play Windows Media singles.

p2p python 0


This looks fairly nifty: Unununium, a thoroughly modular operating system, following the principle that the utility of a system is proportional to the number of connections possible between its components. It's implemented in Python (the kernel contains a Python interpreter), consists of small pieces, loosely joined, and also aims to be completely persistent (so that the machine's state is retained when it is powered off). And, of course, probably won't take the world by storm, though could well become the next Oberon. (via gimbo)

operating systems programming python 0


Python 2.3 is officially out, and brings with it lots of features. Generators are now a first-class part of the language (and not part of __future__), which allows a sort of lazy evaluation; Python can import modules from ZIP files; there is the enumerate() function, which allows you to iterate over a sequence's indices and values more efficiently, as well as Set and Boolean types; and there are a number of nifty new modules, such as a correct CSV handler, and more. Oh, and it's apparently 25% faster too.

functional programming programming python 2


An internal memo from Sun about what's wrong with Java:

  • The support model seems flawed
  • The JRE is very large.
  • Extensions do not support modularity.
  • It is not backward-compatible across minor releases.

Interestingly enough, the memo goes on to compare Java to Python, with Java coming out of it not looking very good.

java programming python 0


The Year in Scripting Languages, a roundup of what happened in 2002 in the worlds of Python, Perl, Ruby, Tcl and Lua.

(Lua? Oh yes, it appears to be a new embedded scripting language of Brazilian origin. No idea what it looks like, as the site doesn't actually show any code.)

"Forget about Basic and go for Lua! Lua is just as easy to use, but a lot more powerful. Lua is also very easy to extend."
-- Jon Kleiser, in

lua perl programming python ruby tcl 0


Via Richard's blog, a USENET rant on why XML is evil. It meanders a bit, in the classic crackpot sense (the extension of the metaphor of XML as a bad child into a reference to diaper fetishism, segueing into a digression on why Americans like big breasts, is but one example), but I must say I agree somewhat with the sentiment; to whit, XML is useful as a markup language for text, but putting everything in XML (as some are advocating) is just silly. For one, for most things, there is too much syntactic overhead compared with other formats, and the idea seems to suffer from the Microsoft Fallacy (i.e., the assumption that clock cycles are too cheap to care about and may be squandered at will).

(I was thinking recently of the data format for a project I've been working on (more info on that later), and was toying with making it XML-based; after all, everybody else is doing it, aren't they? Though I'll probably make it some sort of Python-like pseudocode notation, or something otherwise lighter.)

programming python xml 1


Psyco, a just-in-time compiler for Python. Unlike most JIT compilers, it's a specializing compiler, meaning that it makes several versions of each function, optimised for different data sets. The author claims it can accelerate Python algorithmic code to C-like levels of speed, obviating the need to write C modules. (via NtK)

python software 0



Two Python bits: Deadly Bloody Serious about Python, a new Python-related blog. (via gimbo) And Bridgekeeper, a program for translating Perl code to (variously odd-looking) Python code. (via NtK)

blogs perl python 1


Subterfugue, a system for intercepting and altering system calls from untrusted Linux binaries, scriptable in Python. Get it before it's banned under the SSSCA. (via NtK)

linux python security 0


Nifty: A program which locates found haiku in text files. Well, found senryu, to be precise. (It needs Python 2.2, as it uses generators.) (via bOING bOING)

haiku python text 0


This is cool: Gadfly, a reasonably efficient SQL database module for Python, written entirely in Python (with optional C extensions) and using portable data files. I think Zope might make some use of it too. Mind you, I can't help but think that they could have made it more lightweight by getting rid of SQL text parsing and having a procedural interface for queries. (via gimbo)

database gadfly python sql 0


Guido van Rossum wins a FSF Award, for developing Python. And well deserved, too.

open-source python 0


This looks really interesting: Alphabet Soup, a Python program which generates randomly strange-looking letterforms from elements and a grammar. Currently it works with fragments of bitmaps, but a vector-based version is planned. (ta, Toby)

python typography 0


An article about the state of Cocoa support under Python. In short, some progress is being made with pyobjc (and Python 2.2's improved object system), but it's not there yet.

cocoa osx python 0


Python 2.2 now has iterators and generators, like some of the more outré functional languages (not to mention Ruby and SuperCollider). Here is a good tutorial.

generators programming python 0


Equivalence of Perl and Python imminent? Gun nut and Pythonista Eric S. Raymond wants the two projects to merge their bytecode interpreters, possibly bringing in other languages, such as Ruby and Intercal, to combat Microsoft's all-devouring .NET. The advantages could possibly include the ability to use class libraries across languages, and perhaps even a unified Perl/Python/Ruby/Intercal class library, and the ability to compile any of these languages to C from bytecode (something that apparently is doable in Perl). (via NTK)

perl python 0


Python roundup: An interview with Guido van Rossum, creator of Python, in which he reveals how he wrote the language, and why it will be the next big thing, taking the mantle now held by the popular mutant camel Perl. And if that isn't enough, here's Eric S. Raymond's take:

Ugly programs are like ugly suspension bridges: they're much more liable to collapse than pretty ones, because the way humans (especially engineer-humans) perceive beauty is intimately related to our ability to process and understand complexity. A language that makes it hard to write elegant code makes it hard to write good code.

I agree with ESR; Perl has its uses for quick file parsing jobs, but isn't really suited to large programming tasks (especially when there are better languages). Python is currently my favourite language for day-to-day use. I've looked at Ruby briefly, and it looks possibly more elegant than Python (some of the OO syntax reminds me of SuperCollider on the Mac), though isn't yet quite as mature as Python.

elegance perl programming python 0


You can now get Python for the PalmPilot. Awesome... Mind you, you need a newer Palm than my old Pilot (that's right; not even a PalmPilot; though it does have the 2.0 ROM and 1Mb of RAM).

palm python 0


This looks most interesting: Python WebWare; not as heavy as Zope, but it has some interesting-looking components such as Python Server Pages and WebKit.

programming python web 0


There's an interesting discussion on Slashdot about how human languages influence programming languages, and how languages designed by non-English-speakers would differ from ones designed by English-speakers. (Oddly enough, some of the most elegant recent programming languages come from non-English-speaking countries; Ruby and Python, for example, are of Japanese and Dutch origin, respectively, while Perl is very American. What does this say about the clarity of the English language?)

language perl programming python ruby tech 0

This will be the comment popup.
Post a reply
Display name:

Your comment:

Please enter the text in the image above here: