Fri, 26 Sep 2003
Random links and stuff

Some random stuff:

I've also just noticed that PyPI seems to be getting more popular - yay! If only I had some time to work on it...

path: /stuff | permanent link |
Thu, 25 Sep 2003
Cookie update


path: /stuff | permanent link |
Home office perils...

Rachel's just cooked some chocolate cookies. The smell is extremely distracting. Must go eat warm cookies :)

path: /stuff | permanent link |
Python 2.3.1 digitally signed

Astute viewers might notice that along with the normal MD5 checksum, the Python 2.3.1 downloads also have a GPG signature (the "sig" link):

The signatures above were generated with GPG using the release manager's (Anthony Baxter) public key which has a key id of 6A45C816.

And thanks to a key chain of Anthony → Me → Jim Fulton (we signed each other's keys at the recent Sprint here - thanks Jim!) → Barry Warsaw → <a whole lot of people>, there's a large number of people out there that can verify that Anthony really did generate the file they're downloading from

path: /python | permanent link |
Jeremy Hylton: PyPI Tutorial

Jeremy Hylton has written a PyPI Tutorial:

PyPI: the Python Package Index is the latest attempt to create a comprehensive catalog of third-party Python packages. The catalog is integrated with distutils. This tutorial explains how to use to create PyPI entries.

Thanks, Jeremy!

path: /python | permanent link |
Tue, 23 Sep 2003
DVD fun

We've just bought "Monty Python and the Holy Grail" collector's edition DVD - this is what DVD was invented for:

Yes, it really does have the LEGO version :)

We also got a Goodies compilation which includes episodes from before I was born up to ones made while I was watching the show. Including Kitten Kong. Happy :)

path: /stuff | permanent link |
Gardening, and PyQt is so nice

Last weekend was spent mostly in the garden. It's now early spring, so the weather's warming up and the plants are going ape and are generally in need of some TLC. Oh, and Rachel and I picked out about a couple of dozen new trees to plant, so they had to go into the ground too.

I'm in terrible shape though, so on Saturday I planned ahead and we went out for dinner (Shakahari, one of the best vegie restaurants in Australia) which was yummy, as always. After a night's sleep, I was reminded just how unfit I really am, so I spent Sunday doing mostly small cleanup work instead of more weed removal.

Eventually, I stopped that and played with another programming side-project which I decided needed a GUI. I've previously used PyQt for various things, but this time I had a potential audience that couldn't be stuffed installing PyQt. So I tried tkinter. Ugh. Never again. Ugh.

A couple of hours later, I'd used Qt Designer to create five interfaces and I'd wired most of my existing code into those. Painless! Except now I need to get my audience to install PyQt, which can be anything but painless. I can't even get sip to compile on OSX, let alone trying for PyQt itself. Ah well, it's a good thing I've got Linux too :)

path: /python | permanent link |
Sun, 14 Sep 2003
Colour printer/scanner/copier, way Linux friendly

Rachel's venerable old printer died a while back, and we've just gotten around to replacing it. We like the colour printer / scanner / copier combos, so after shopping around, we found that the HP offerings were quite nice. I did a quickie check, and found that the particular model (PSC 2110) we wanted to get was supported under Linux.

What support though! The printer and scanner drivers are maintained in sourceforge projects supported by HP. And they just plain work out of the box!

The quality is good too - I printed one of my old photos out on one of the sample photo paper sheets that came with the printer, and it's pretty good. There's banding when you look closely, but it's not noticeable at a viewing distance.

path: /stuff | permanent link |
Intersting web diary at the SMH

The Sydney Morning Herald has a web diary with a number of contributors (from around the country, not just Sydney). I've only just noticed it, and it has some interesting entries. Stuff like "Howard on the ropes: Labor's three chances for a knockout blow". Going to keep an eye on that one...

path: /stuff | permanent link |
Random links

Some random links (short list this time):

path: /stuff | permanent link |
Fri, 12 Sep 2003
What I've been up to...

Well, this week I demoed the new version of the software I'm working on to the company as a whole, and then to some outside interested parties. Stuart (the other developer), the lucky blighter, was scuba diving in Thailand during the lead up (and possibly on the first demo day too). The demo went really well though, with positive noises from all involved. That's always a nice outcome :)

The code has a couple of utility modules that I'll release if I can find the time. I've only been able to scrape together the most superficial personal involvement in Roundup recently, so I'm not sure whether I really should release any more code... The first module takes several chunks of text and formats them into columns (plain text, of course). At the most basic level, it does what the Python2.3 textwrap module does, but extends that to handle the multiple columns. The other module is a Zope interface to the module that I snarfed from amk and extended and contributed back to the pycrypto project. If anyone's interested in this code, let me know and I'll fire the module your way...

And now for something completely different:

Aoccdrnig to a rscheearch at an Elingsh uinervtisy, it deosn't mttaer in waht oredr the ltteers in a wrod are, the olny iprmoetnt tihng is taht frist and lsat ltteer is at the rghit pclae. Therset can be a toatl mses and you can sitll raed it wouthit porbelm. Tihs is bcuseae we do not raed ervey lteter by it slef but the wrod asa wlohe.

Thanks, Anthony, for that. He also pointed to some related news.

path: /stuff | permanent link |
Fri, 05 Sep 2003
Random links

More random links (not many today):

path: /stuff | permanent link |
Tue, 02 Sep 2003
Python anti-pitfalls

The following are a quick (random, off the top of various heads) list of things that I think are anti-pitfalls in Python. That is, because the language has these features, it is harder to make programming mistakes.

Thanks to Dougal, Anthony and Toby for running their eyes over this list, and for their suggestions.

1. Everything's a reference to an object (no magic line-noise)
Python doesn't have a separate scalar / reference syntax! Celebrate!

Dereferencing is one of the hardest concepts for a new programmer to learn, and I know from personal experience that some people gave up on the whole programming caper just because they didn't understand pointer arithmetic and dereferencing in C.

Aside: perhaps it might be because it's such a fundamental pitfall in other languages that people coming from them have such trouble coping with python's "names for objects" approach. How many times have we seen new Python programmers despairingly ask "how do I pass by reference"?

Pitfall avoided: Many and various errors due to not getting the magic line-noise quite right or not fully understanding the concept of dereferencing.

2. Real polymorphism
(or rather, not that jumping-through-hoops, interface-tied, type-casting-up-the-wazoo anticipate-all-use-cases polymorphism that some languages force on users)

Everything's an object and there's no built-in type checking on arguments. Interfaces generally evolve through consensus - if a function is written that accepts a file object argument to read data from, then any object that implements a read() method will do as a substitute argument - a StringIO instance, the result of a urllib.urlopen() call, a socket, etc.

Combine with built-in variable argument lists and keyword argument lists (with default values) for a really satisfying taste!

Pitfall avoided: Inflexibility due to not anticipating some new use of your code.

3. Sequence unpacking
I use it so much. Mostly just automatically too when returning multiple values from a method/function. And "a,b = b,a" does the right thing.

Pitfall avoided: Messy code.

4. The call operator
Bound methods, functions, classes... all use exactly the same interface and all are first-class objects.

Pitfalls avoided: Having to deal with (and remember) the different ways of calling different callable things. Also, like #2 you don't have to worry about what kind of callable you might get if you accept one as a function argument.

5. Automatic memory management

Also under this heading could be the complete inability of user input to mangle code and take over your system (caveat: no use of exec/eval).

Pitfalls avoided: Memory usage going out of control. Your system being compromised because you didn't bounds-check some string from the Real World.

6. The print statement
A lot of other languages have a print statement or function but Python's is particularly good at just dumping a bunch of information in human-readable form. It just works. This is mostly because many/most builtin objects have useful repr methods.

BTW, I think it's a good thing that it adds spaces, even with a dangling comma. If I want fine control over output, I'll use sys.stdout.write().

Pitfall avoided: Inability to just have a gander at what's going on.

7. Indentation for structure
Not only does this save typing, but it also means that code is far more readable than in some other languages.

Pitfalls avoided: Unreadable code. Strange errors due to not using block delimeters when you should have used them.

8. Ubiquitous, unencumbering exception system
It's available and used everywhere, and you don't have to trap exceptions if you don't want to. Trapping exceptions can be as fine-grained as you like, and you can send an arbitrary object of information along with the exception. Now that's nice.
9. Introspection
From Dougal: you can poke into any object. You can test whether objects have attributes, or whether they're callable, or...

Pitfall avoided: Like #6, you can get in there to understand what's really going on in your own code.

10. Feature-full, rock-solid, simple built-in types
It can be argued that a lot of problems are averted just by having the solid built-in string, tuple, list and dictionary types. The potential problems in other languages being errors in implementing those types or using half-assed attempts at implementing them.

Pitfall avoided: Half-assed basic type (re-)implementations.

11. No namespace pollution (unless you really want to)
Another from Dougal: Python doesn't automatically pollute namespaces unless you specifically force it to with statements like "from foo import *".

Pitfall avoided: Namespace pollution, and the strange side-effects that occur.

12. The python shell (interactive interpreter)
From Toby: "if for no other reason than that i don't need a calculator any more ;)". I definitely echo that sentiment, and more... The interactive interpreter prompt lets new and experienced Python users alike muck around with code to see what it does. I couldn't imagine developing regular expressions without the interactive shell :)

Pitfall avoided: This is more a tool for avoiding a bunch of errors you might have run into without the ability to test ideas and code fragments out.

13. PDB
From Anthony: PDB, the built-in debugger. I'm not sure this consitutes an anti-pitfall, but it's definitely on his list. The magic string you're looking for is "import pdb ; pdb.set_trace()" When the code hits that you'll be dropped into the pdb shell. Nice.

Pitfall avoided: When things do go wrong, you've got the direct ability to get elbow-deep in the live program to see why it went wrong. And to change that live program then and there if necessary.

14. Treat programmers with respect
Python treats programmers as intelligent people. It doesn't specifically put barriers in their way which can cause confusion (eg. public/private/protected attribute distinctions that are circumventable in some other language implementations anyway, leading to horrible, horrible code).

Pitfall avoided: Treating programmers like babies, asking them to be overly explicit in every little thing they do, and locking them out from things that they might hurt themselves on.

path: /python | permanent link |