14 Aug 2006

python 2.5 beta 3 ebuilds

i've been playing around with python 2.5b3 in the past week. i've have a set of updated patches and ebuilds in my overlay, but they should make it into portage hard masked sooner or later.

some highlights, even though i haven't used any of this in code that i write:

1. ternary statements (like in C's int a = b ? c : d). the new syntax is `x = true_value if condition else false_value`. i haven't had the chance to use it properly, but i would probably use it like this:

>>> x = {}
>>> y = 1 if x.get('y') else 0
>>> y

2. partial functions. this is quite cool because it means finally we can have proper partial functions, not like the interesting currying methods used in things like django, and demonstrated on the activestate pages.

3. try: except: finally: now works like java's exception handling. this was one of the things that irked me about python with their condition that finally and except cannot mix.

4. elementtree and sqlite are now part of the standard library. that is great because i do all my XML parsing in elementtree, so now i don't need to install it everywhere. sqlite is a nice addition, it will be a good alternative to berkdb and gdbm that is already in python standard lib.

speaking of new python features, i've only just really started getting the concept of decorators (introduced in 2.4). they're pretty awesome once i finally got my head around getting to work (which involves a decorator-function that returns a decorated-function calling the decoratee-function!)

You can reply to me about this on Twitter: