This post originated from an RSS feed registered with Python Buzz
by Ben Last.
Original Post: A Twisty Turny Thing
Feed Title: The Law Of Unintended Consequences
Feed URL: http://benlast.livejournal.com/data/rss
Feed Description: The Law Of Unintended Consequences
The BlackAdder quote in full is "You twist and turn like a ... twisty-turny thing", and I refer to the interesting contortions through which PythonWin goes in it's admittedly impressive attempts to be an IDE written in the same language that it supports. I've spent a fair amount of time in PythonWin over the last couple of weeks (when I say in, I mean interacting with it, not poring over the source code like Gandalf looking to identify the Ring[1]), using it to develop a crafty little system that generates questions from a database of "facts"[2]. It's the sort of batch process that, once kicked off, runs overnight, using around three thousand input records to generate several thousand output ones. Most of the heavy lifting happens in Python, which builds up networks of object to represent the datums and relationships therebetween. It's cool, and pretty memory-intensive.
So a lot of the think-write-read-run-debug cycle is done via PythonWin and, let me tell you, that little near-the-taskbar icon that lets you drop into running code is a blessing from whatever Gods watch over programmers. I remember missing the sublimely simple tactile trigger of Control-C when I first started using Windows (in those days I was more a VMS and Unix type of lifeform), the ability to, in effect, say "Oi! Program! No!" whenever one ran amuck. Windows doesn't give you that. You can, of course, try the little Fisher-Price "X" icon. Which sends the application a polite event to ask it, if it wouldn't mind, to be ever so terribly helpful and close. PythonWin in full flow doesn't respond, and not unreasonably so. You can then try the right-click-on-the-taskbar-wotsit, which tends to be doubly frustrating, since the menu pops up and down like... well, I'll let you supply your appropiate humourous metaphor here. Again, the Close option doesn't so much close as not. One yearns for the power of Control-C as one gives the three-finger-salute and conjures up Task Manager like some Demon from the nethermost slums of Pandemonium and commands it to End Process.
Or you can blithely click on the little coiled green snakey thing in the area of the screen that is apparently not called the System Tray really and choose to Break Into Running Code. I like that; there's a certain burglariousness about it, and it's satisfying to see the same old command-line-esque KeyboardInterrupt exception launched (I like to imagine) on a ballistic course to crash through the thicket of namespaces and pin the interpreter, writing and flailing, to the ground.
Anyway, none of this is the fault of PythonWin, which is really dead dead clever, but is written in Python. And thus contains the seeds of its own weakness, for occasionally, after Breaking Into that Running Code, a fountain of traceback bursts onto the interactive window (that's the window inside the PythonWin window, not the PythonWin window itself, which is a container window for the other window, to be clear) and after that, all bets are off. Now clicking the X or choosing to Close will result in just another traceback, and another, one per click. The Window That Would Not Die. For, of course, as well as my code running, PythonWin itself is also running, so that KeyboardInterrupt missile is as likely to clobber the one as the other.
But I do like PythonWin, genuinely I do.
[1] You can assume from this that, like many other LOTR fans, I celebrated the release of The Return Of The King by watching the whole lot over several evenings. Let joy be unconfined. [2] As per usual, I omit the identifying details of what I'm actually working on because, hey, I signed NDAs too, you know.