benlast ([info]benlast) wrote,
@ 2004-05-28 15:08:00
Previous Entry  Add to memories!  Tell a Friend!  Next Entry
Current mood: geeky

A Twisty Turny Thing
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.




(Post a new comment)


[info]metamoof
2004-05-31 01:54 am UTC (link)
Out of the IDEs I've tried, Pythonwin is the least full of twiddly bits, but at the same time, I've found it the most useful at getting things done. And the interactive debugger, MS Visual *-style, actually does a reasonably good job, too.

At the same time, I do find that the fact that pythonwin itself is running in the same interpreter, and even the same namespace is incredibly annoying, sometimes. I work a lot with COM objects, and when running a bunch of tests on a COM object, you actually have to restart pythonwin every time you change the library being accessed over COM due to the way windows caches its objects, which is reasonable enough. Also, sometimes it's a bit difficult to randomly reload a module that's already been imported elsewhere in a convoluted import tree.

In the latest build (200), I've noticed this breaking into running code making the pythonwin interface inactive for certain things, including rather crucial bits and bobs like the "Quit" command, or the big red X button.

But these failings are fair enough, and you learn to live with them. I've learnt to live with them by having wxPython's pycrust on what should be called the app bar, and using that for prototyping and quick tests, while keeping pythonwin for editing and running more extensive tasks. Oh, and the pycrust Copy Plus and Paste Plus commands are wonderful for this sort of interaction.

(Reply to this)


Create an Account
Forgot your login or password?
Login w/ OpenID
English • Español • Deutsch • Русский…