Skip to content

Entries published on October 28, 2006

1 entry published on this date. See also: all entries published in October 2006, full archive.

Python tips: don’t be too concise

There’s an inherent tendency programmers have to take a piece of code and reduce it to the shortest possible form. The holy grail is, of course, cutting something down to a single line of code while still providing the same functionality; reducing a particular piece of code to a “one-liner”, especially if the code is somewhat complex, is sometimes viewed as a measure of a programmer’s intelligence or talent or both, and is often used as a sort of game (see Perl Golf, for example — the cult of the one-liner is stronger in Perl than in almost any other language).

And in a lot of cases it’s good to reduce code where possible; usually, if you’re able to shave a line or two, or cut out a few expressions, it’s because the code wasn’t written as clearly as it could have been, so you end up with something that’s functionally …

Entry published October 28, 2006. Read full entry.