Python ternary operator

Today’s Python discovery:

Python doesn’t have the C style ?: ternary operator (e.g.: cond ? valueIfTrue : valueIfFalse).

But as of Python 2.5 it has a ternary operator with its own syntax: value_when_true if condition else value_when_false

For example:

>>> ‘a’ if 1 == 1 else ‘b’
‘a’
>>> ‘a’ if 1 == 0 else ‘b’
‘b’

This is actually clearer and more Pythonic . . . → Read More: Python ternary operator

TiVo HME SDK for Python

Just stumbled up on this (via TiVoBlog who in turn found it via TiVo Lovers) and will have to give it a try sometime:

From TiVo HME SDK for Python:

An implementation of TiVo’s HME (Home Media Extensions) protocol for Python, as a module (hme.py), a simple server (hmeserver.py), and examples (mostly ported from TiVo’s Java HME SDK). . . . → Read More: TiVo HME SDK for Python

Hacking OS X’s Python dbhash and bsddb modules to work

By default on my Leopard system, the dbhash and bsddb Python modules cannot be loaded.

marc@hyperion:~$ python
Python 2.5.1 (r251:54863, Oct 5 2007, 21:08:09)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.
>>> import dbhash
Traceback (most recent call last):
File “<stdin>”, line 1, in <module>
File “/System/Library/Frameworks/Python.framework/Versions/2.5
. . . → Read More: Hacking OS X’s Python dbhash and bsddb modules to work

reviewboard – Google Code

Just started using this at work for code reviews and it looks impressive and useful so far.

reviewboard – Google Code

Incidentally, it’s written in Python, . . . → Read More: reviewboard – Google Code

links for 2007-07-22

The Eric Python IDE
Eric is a full featured Python and Ruby editor and IDE, written in python. It is based on the cross-platform Qt gui toolkit, integrating the highly-flexible Scintilla editor control.
(tags: python ide programming . . . → Read More: links for 2007-07-22

links for 2007-04-08

Python for Lisp Programmers
Peter Norvig compares and contrasts Python and Lisp (esp. Common Lisp)
(tags: python . . . → Read More: links for 2007-04-08

New features in JavaScript 1.7

Firefox 2.0 includes JavaScript 1.7 – here’s a breakdown of the new features.

Looking at this list of features, which includes destructuring assignments, generators, and list comprehensions, it seems to me that the Mozilla guys must have been heavily influenced . . . → Read More: New features in JavaScript 1.7