September 2008

Python inline conditionals

tung's picture

I used to always use this:

x = cond and y or z

Resulting in setting x to y if cond was True, or to z if not. It does some funny things if you throw zeros into the mix, but it's usually good.

Over here is the 'proper' Python way of doing things:

x = y if cond else z

I didn't even know that existed.

Here's a trick with tuples, similar to the first:

x = (y, z)[cond]

It works because True and False in Python can be treated as 1 and 0, respectively. Watch out though, it still evaluates both y and z.

Read more »

A Lisp that's nice to use?

tung's picture

Common Lisp is frozen at its core. Scheme is too theoretical. Arc, the 100-year language, I'm sure will be useful in 100 years. What's a Lisp programmer to do?

We don't need a thinker! We need a doer! Someone who will act without considering the consequences! -- Homer Simpson

I want to make my own Lisp, with one requirement: it should be nice to use.

Read more »

Why I use Linux

tung's picture

I just realised that if I were to be involved in a conversation and asked about why I prefer Linux over, say, Windows, I wouldn't have a reasonable response. It'd be something along the lines of, "I just like it better." There must be more to it than that.

I'm certainly no freetard, so there must be some practical basis to my choice of operating system. In no particular order, here they are:

Read more »

dailygrind desklet

tung's picture

Don't be the example, multiple entries can appear in each section

dailygrind is an adesklets widget that keeps you informed of repetitive tasks. Things that you do every day, you need every week, every month, every year, or even just a once-off, are all shown in a small box on your desktop.

Read more »

Lazy as the Fist of the North Star

tung's picture

Okay, I haven't updated this thing for a while. What gives? I've been avoiding this because I don't like to be reminded of the fact that I need to upgrade Drupal (game on, hackers). I guess it doesn't help that upgrading Drupal is a simple matter of...

Read more »