On Fri, 28 Apr 2006 16:39:33 -0700, nikie wrote: > I V wrote: >> Do you need the generator expression here? dict(enumerate(L)) should be >> equivalent, no? > > I think the generator is needed to swap the item and the index. > dict(enumerate(L)) would yield a dict like {0:'C', 1:'A'...}
Oh, of course, I wasn't paying attention. >> Incidentally, does python have a built-in to do a binary search on a >> sorted list? Obviously it's not too tricky to write one, but it would >> be nice if there was one implemented in C. > > I once read in an algorithm book that it took 10 years from the first > binary search publication until a correct version was published, so, it > actually is a bit tricky... Better stick to the bisect module. Don't > know if it's written in C, though. Thanks for pointing out the bisect module - that's exactly what I was looking for. -- http://mail.python.org/mailman/listinfo/python-list