Python's extra-clever function parameters

I'm not sure where I ran across this, but until recently I wasn't awarethat you could pre-explode lists and tuples when you declared whatparameters a function takes. That sounds stilted, so I'll give anexample:

def foo(a, (b, c, d)):  print a, b, c, d

This is slightly more compact than the equivalent:

def bar(a, tmp):  b, c, d = tmp  print a, b,

霍元甲


星期六下午看了“霍元甲”,電影比我想像中好,很久沒有看到這麼沉實的武打片了,而這部號稱李連杰最後一部武打電影,除了打出精彩動作,更拍出了武打片中罕見的深度。

我覺得此片處理得比較好的是後半部霍元甲家破人

刻度

如此潰爛的生日,以前也試過嗎——其實我已經不記得了。幾天前的事都已像乾澀的粉刷抹過,一片迷糊,而刺鼻。 我什麼都不記得了。

我拒絕了母親和學生的約會,把自己鎖在斗室裡。收到認識的人的電話、很久沒見的朋友的

Weekly spam summary on February 25th, 2006

Here's how Hotmail stacks up this week:

  • 4 messages accepted; unfortunately, one of them was definitely spamand at least two more probably were.
  • 21 messages rejected because they came from non-Hotmail emailaddresses.
  • 49 messages sent to our spamtraps.
  • 4 messages refused because their sender addresses had already hitour spamtraps.
  • 6 messages refused due to their origin IP address, all for beingin the SBL ; four from SBL17935 ,one from SBL27471 ,

The hassle of email (as compared to RSS)

In my recent 'give me RSS feeds' entry I wrote in passing '[...] these daysemail is just too much of a hassle'. Which it is. Let me illustrate how.

To subscribe to new mailing lists these days I need to:

  1. figure out how to subscribe
  2. make up a new email address to give the list
  3. go through a multi-stage subscription dance
  4. make sure our antispam filters won't eat the list messages
  5. adjust my filters to put the messages somewhere distinct
  6. remember to check

如同沒有,時間的刻度

其實算挺糟的:我完全無法寫工作上的東西,只能筆戰。一旦有要靜下心來做的事,就像決堤一樣癱軟下來。 我不知我怎麼可能寫完論文。

每當時日過去,我覺得自己想要扭頭細數人生,就以這詩來抵擋。每一句都打擊我的心臟

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


表面的和平



如果你當過討論區的版主你一定會知道,現在的討論區每一帖都隨時有機會變成罵戰,喜歡兒戲地侮辱的人,往往最受不了別人的反駁和批評。結果我常常收到的是“你刪了我那張帖,為甚麼那個人的你又不刪?”、人身攻擊過

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