A trick for handling mutable default arguments

One of the neat things about programming in Python is finding out aboutclever little idioms that are obvious in retrospect. My latest find isa little trick for handling mutable function arguments.

As I mentioned back when discussing the consequences of def beingan executable statement , the way I'd beenhandling mutable default arguments was something like:

def foo(a, blst = None):  if blst is None:    blst = []

At two lines, this is just verbose enough to grate lightly butirritatingly on my nerves


More clever (ab)use of and and or

In a comment on the last entry Imumbled yet again how I was annoyed that Python doesn't have anequivalent of C's '? :' conditional expression operator. Thensome neurons in the back of my mind woke up and asked 'didn'tGuido van Rossum say he was going to add this to Python 2.5 ?'

In the process of trying to figure out if thiswas still happening (it is), I read this message (via here )and found out about a


20060225網摘 – 地海戰記預告片

Bookmarklet

動漫

快快手手


Wanted: RSS feeds for vendor software updates

Vendors, I have a simple request for you: give me an RSS feed foryour security fixes and system updates . No, please don't suggest thatI subscribe to your email announcement list, because these days emailis just too much of a hassle. Accept it; RSS is the new lightweightnotification format, and notification of new updates is just what Iwant.

And don't just give us one global RSS feed of everything. Be modern; letpeople get narrow feeds as well as broad ones


復古 Google Page Creator

googlepagecreator

Google 又有新的玩意了!不過這一次是舊酒新瓶:在線網頁編輯器 Google Page Creator

這個編輯器十分簡單易用,預設很多不同的 Themes 可供使用,共有四款 Layout, 不用花太多的氣力就可以做出一個不錯的個人頁面。大量使用 Ajax 的編輯介面,使其更像


Checking systems with RPM verification (part 1)

I spent part of Monday poking through a Fedora Core system that hadbeen partially compromised, and I was reminded yet again how one of myfavorite RPM features isn't as widely known as it could be. Namely, thatRPM keeps a handy database of the MD5 checksums about every file it'sinstalled (as well as a pile of other information). The rpm command's -V option taps this database to verify the actual files on the systemagainst what the database says they should be and


如同不曾移動

因為不喜歡扭動鑰匙,我有一間不上鎖的屋子,並時常呼籲朋友自行開門,放下東西或在裡面休息。但我在屋裡的時候,則總會將木門反鎖,因為在裡面開啟木門不必動用鑰匙。某些時候,我則會進一步將鐵閘以小鎖鎖上。這是

20060222網摘 – 二次創作

Tutorials and Tips

Design

Web Application

  • iRows 另一網上 spreadsheet 應用

Peter Drucker on the Five Deadly Business Sins

Every so often I read a genuinely electrifying article, one that makesme sit bolt upright in an 'ah-ha!' moment as it crystallizes things I'vebeen stumbling towards.

Peter Drucker's The Five Deadly Business Sins is one such article. Go read it now; I'll wait. (It nailed me to thefloor so much that I have a copy saved in case the Wall Street Journalever removes it or moves it behind their pay-wall.)

Looking back over my entries


An annoyance with $PATH on Red Hat

In the spirit of equal opportunity annoyance :

One of the things that never fails to irritate me with Red Hat is thatwhen you do ' /bin/su root ' on astock system, you get a shell whose $PATH doesn't include /sbin or /usr/sbin .

This trips me up all the time, and every time it's an nngh moment. Andit's not as if Red Hat doesn't already have a ~root/.bashrc that doesquite a lot