Skip to main content

Posts

MochiKit 0.5

MochiKit is a platform-agnostic javascript framework that doesn't suck. (Here's the release announcement , following the announcement of a public subversion repository a few days ago.) The documentation alone should make MochiKit the preferred js library. It's a huge improvement over the alternatives. Bob Ippolito has been working on MochiKit for a while. I've learned a lot from his javascript blog posts as he's worked on it. If you think you know javascript, but don't know what a prototype is (I didn't), you need to read his blog. (Yes, Bob knows about JSoLait and Prototype. He doesn't like them , and gives excellent reasons for the genesis of MochiKit.)

iXP

I love Mike Spille's blog. He doesn't post terribly often, but when he does it's always worth reading. Here he is with a savagely funny mock of XP . Rule 0. Whenever you type an 'i' - drink! . Also known as the zeroeth iXP rule. While the vision began with Alternate Letter Pair Programming Order, mentioned below, it's really this rule that made iXP gel, and which differentiated it from previous similar practices.

Spyce testimonials

Since the Daily Python URL was kind enough to link to the 2.0.3 announcement, I thought a few testimonials might be in order. :) I tried downloading, installing and using Spyce 2.0.2 on Windows and Linux yesterday and it worked like a dream. I have already set up a useful little dynamic site on a linux box and plan to expand it radically in the weeks ahead. I am using Spyce in webserver mode and also using the scheduler to trigger periodic repository updates.     -- Rock Howard Spyce is really speeding up my "project"... at this rate, I'll be ready for pre-beta testing in about two months. I'm utterly addicted to encapsulation via active tags.     --Tim Lesher (Not to pick on them since they do have a nice framework, but Tim was formerly using CherryPy. Most recently, anyway. )

Spyce 2.0.3 released

2.0.3 is a bugfix and documentation-improvement release. The installation section of the manual has received particular attention. There is also the new section on starting your first project , which answers the FAQ, "how do I organize my Spyce files?" Changelog: - fix pool bug if server not in concurrency=threaded mode; reported by "Dude" - documentation improvements - avoid stomping on user python modules named 'config'; reported by Betty Li - (John Reese) fixed bad interaction of "redirect if directory path doesn't end in /" and "look for default index.$[index extensions] files" code in Spyce webserver - default concurrency mode for Spyce webserver is 'threading' instead of None - spyceProject script to automate new-project creation Update: you may also be interested in the new testimonials post.

on Broken Pipe and Connection Reset By Peer

Maybe I'm just dumb, but I always thought "broken pipe" meant, "the other end of this socket closed before I finished sending something" and "connection reset by peer" meant, well, roughly the same thing. (As well as indicating some slightly more esoteric problems.) Turns out though, "broken pipe" actually means "I just tried to send something and the socket was already closed to sending." So in the following example, if the other end of (TCP) socket "sock" closes or dies before the write method, "connection reset by peer" will be raised. The next write will give a broken-pipe error, since the socket now knows that further sending is invalid. try: sock.write('foo') except: pass # connection reset by peer sock.write('bar') # broken pipe

Jython is back

After almost two years with no releases, Brian Zimmer has released an alpha version of Jython 2.2 (incorporating some of the patches I submitted back in Jan 04). Ha! Brian, you will recall, got a PSF grant for Jython and started work earlier this year. Obviously his original estimate called for a much faster release, but that's how software development goes. Six months to a release after inheriting a new-style class branch that I suspect was mostly broken really isn't too shabby, especially considering how long it took the CPython team. I haven't been following Jython development since I gave up hope of Samuele Pedroni ever getting a release out last year, but it's clear that Jython isn't a one man show anymore. Frank Wierzbicki and Clark Updike have been comitting code; almost certaintly there are others too that I didn't immediately notice. Frank and Clark have both been involved with Jython for a while, but new developers are getting involved too....

How well do you know python, part 8

Here is a mostly-functioning class that facilitates writing producer / consumer algorithms. It is designed to support a single producing and multiple consuming threads, i.e., scenarios where consuming involves some blocking operations such as communicating over a socket. "Mostly," in this case, means that there are two bugs in this class that can be fixed in a total of four or five lines. One is arguably more subtle than the other, but they involve the same part of the code. Can you spot them? Warning: this one is tougher than part 2 , which also dealt with threading. import Queue as queue import threading class PCQueue: def __init__(self, initialthreads): self.q = queue.Queue() self.running = True self.condition = threading.Condition() for i in range(initialthreads): self.add_consumer() def run_consumer(self): while True: self.condition.acquire() try: self.condition.wait...

Two Wax projects for Summer of Code

The PSF put up a list of projects accepted for Google's Summer of Code . Not one, but two projects deal with improving Hans Nowak's Wax toolkit. Very cool: hopefully by the time I have to write another desktop-bound application, Wax will be mature and well-documented. Tkinter is too underpowered, and wx is too clunky. That's why I added Wax to the SoC coding project ideas wiki, although it wasn't immediately clear if this was welcome. Glad it worked out. (Two people working on Wax is old news if you read Hans's blog . Which I haven't been, inexplicably. Ah, well.)

Of all the things I've lost...

I installed a sys.excepthook in my project at work that uses the logging module to record any uncaught exceptions. It didn't work. I did what any lazy programmer would do: ask someone more experienced. "Do you have to set sys.excepthook in each thread?" I asked, more-or-less. "I don't think so," he replied. Hmm. Maybe the developer I'd taken over from was setting excepthook later on in the initialization or somewhere else. ... Nope. Finally I wrote this: import sys, threading def log_exception(*args): print 'got exception %s' % (args,) sys.excepthook = log_exception def foo(): a = 1 / 0 threading.Thread(target=foo).start() Playing with this a bit demonstrates that sys.excepthook doesn't work in subthreads, at all . The documentation doesn't mention anything of the sort. Smells like a bug to me. (I did file one .) I belatedly googled "sys.excepthook threads." (I must have been a bit slow this morning to no...

The tale of a wiki diff implementation

I run a web game that I started in late 2000, back in the Dark Ages before there was a decent python web toolkit. It runs on a then-current version of the OpenACS TCL-based toolkit. (at around 20kloc, porting it to a more modern system wouldn't be worth the effort now.) Recently, a player suggested that I add a wiki, since my own documentation is chronically out of date and player-run sites tend to suffer bitrot as well. (How many games are you still playing that you started 5 years ago?) So, I backported a modern OpenACS wiki module -- no trivial task; a LOT has changed in OpenACS, and not all for the better -- and was set. Except the module I backported didn't have diff functionality, probably because the various TCL options mostly suck . Enter TclPython , a tcl module by Jean-Luc Fontaine (who is obviously a far better C hacker than I) that embeds a python interpreter. Sweet! My life just got a lot easier: package require tclpython set py [python::interp new] #...

SF.net examples fixed, again

This time I apparently broke it by copying the development spyceconf.py, which among other things references the authentication tag that doesn't exist in 2.0, into the sourceforge site. Oops. (The 2.0.2 release itself wasn't affected.)

I figured out why Python's threading library bugs me

Reading Aahz's 2001 OSCon presentation , I ran into a slide that crystalized it [paraphrased]: Perl: There's more than one way to do it Python: There should be one (preferably only one) obvious way to do it Python's threading library is philosophically perl-ish That pretty much says it all. Well, that and the main classes are (still) virtually undocumented. Update: I'm referring to the synchronization classes in this module, not the Thread class, which is straightforward enough.

Why PHP sucks

(July 8 2005) Apparently I got linked by some PHP sites, and while there were a few well-reasoned comments here I mostly just got people who only knew PHP reacting like I told them their firstborn was ugly. These people tended to give variants on one or more themes: All environments have warts, so PHP is no worse than anything else in this respect I can work around PHP's problems, ergo they are not really problems You aren't experienced enough in PHP to judge it yet As to the first, it is true that PHP is not alone in having warts. However, the lack of qualitative difference does not mean that the quantitative difference is insignificant. Similarly, problems can be worked around, but languages/environments designed by people with more foresight and, to put it bluntly, clue, simply don't make the kind of really boneheaded architecture mistakes that you can't help but run into on a daily baisis in PHP. Finally, as I noted in my original introduction, with PHP, ...

Anders Heljsberg doesn't grok Python

While Debian was releasing Sarge and Steve Jobs was introducing MacX86 yesterday, Anders Hejlsberg spoke on C# at Microsoft Tech-Ed . James Avery writes : After a couple questions from other people I was able to get in the other question I was dying to ask. What does Anders think about the resurgence in dynamic typing from languages like Python. Basically he said that he understands what benefits people are getting from dynamic typing, but he thinks they can get the benefits of dynamic typing without sacrificing strong typing. He talked about inferring type (what anonymous methods do now with delegates) and how that might be a way to get the coding speed and ease without sacrificing the strongly typed information. Unfortunately, omitting type declarations is only a small part of Python-esque dynamism. One of the smallest, in fact. Far more important are the ability to modify objects and classes at runtime, which allow you to do things in Python that would require code generation (w...

Spyce 2.0.2 released

Second bugfix release. Get it here . Changelog: session_dir uses config.tmp by default if no directory is specified fix for session_dir pickling on win32 fix for fileCache pickling bug on win32 reported by Jaros³aw Zabiello fix for sessions + handlers problem reported by Jonathan Taylor * all module init() methods are now run before handlers are called.

How well do you know Python, part 7

Given the following two classes, class A: def foo(self): print self.__class__.__name__ class B: pass why does this work, def bar(self): print self.__class__.__name__ B.foo = bar b = B() b.foo() while this does not? B.foo = A.foo b = B() b.foo()

Utah Python User Group

The former Provo-Orem Python Meetup Group is now the Utah Python User Group . I've set up a rudimentary website and discussion list; anyone interested in Python is welcome to join the list and/or attend the monthly meetings (next one on June 9th). (We're already on the user group wiki in case utahpython.org is hard to remember. :)

Spyce 2.0.1 released

Spyce 2.0.1 is available over at the usual place . This is a bugfix release. Changelog: use tempfile.gettempdir() as default config.tmp add originalsyspath to spyceconf bugfixes for Active Tag compiler portability & other bugfixes (John Reese)

Spyce vs ASP.NET

A former co-worker asked me over IM, What advantage, other than being able to use it on a Linux box, does [Spyce] have over the ASP.NET Model? Because I can tell you, with Visual Studio, I feel pretty productive. I answered, The main one is a significantly shallower learning curve. Once you know how the ASP.NET event model and page lifecyle work, you are set -- but you remember how "easy" that was for [our] students. With Spyce there is only one rule: handlers run before the rest of the page, in the order they were added. That's it. And, of course, Spyce runs Python. This is significant: Python is addictive; once you start writing code in it, it's painful to use less-expressive languages. This is something most people won't get until they try it, unless maybe they are old-school Lisp hackers. Now, Spyce isn't quite to the point where it matches ASP.NET feature for feature. But it's close, and getting closer. I checked in an authentication...