Python modules should not reinvent OSError

In light of yesterday's entry , here is one of my newrules for Python modules, especially extension modules written in C:

If you're going to raise an exception because a system call failed,don't make up a new exception for it. Raise either IOError or OSError themselves.

Every deviation from this causes annoyancesfor Python programmers. This is especially visible in the situationwith signals and EINTR , where I really do not want tobe rewriting the same code over and over again with different exception


跋足狂奔的生還者


今日是 “workcamp free day“ ,即是義工們在工作營期間的假日。我們在清晨便離開木屋,準備下山去,這是我們第一次下山到市中心去!
在那段下山必經的 斜坡,我和另一義工都仆倒了,褲管沾滿了泥濘。我們在國家公園內步行了二個小
Continue reading...

極端


黑白分明是良好的願望。

小朋友看的卡通片,主角好壞分明,絕不混淆。可是現實世界的人和事,除了黑白兩種色,還有沒有別的顏色?

也許是卡通片看得多了,我們身邊總有一些想法簡單的成年人,誤以為小城的大小事務都是

在森林和原野

是的,上文提及那河流就是山下那條可通往北冰洋的葉尼塞河。

需要到山下的河流洗澡可不是令我們一眾人感震撼的主因,背後的食水儲備問題方令我們真正的擔憂起來。原來木屋主人沒想過我們一眾義工需要使用食水,所以他
Continue reading...

工作營第一日

工作營的俄藉Camp Leader昨夜建議我明早到克拉斯諾亞爾斯克市中心的中央警局報失背包,但俄羅斯警察的官遼風氣甚盛,她着我要有心理準備那可能會折騰大半天。
昨晚我真的完全睡不着,眼光光望天光,整晚想着旅程才剛開始就發
Continue reading...

Link: Using colour well in data visualization

Why Should Engineers and Scientists Be Worried About Color? is abouthow straightforward use of colour in data visualizations can mislead youand hide information (and how to do better). Some of their examplesare eye-opening and alarming.

(Via Hacker News .)

(Since I took up photography I've had a muchincreased interest in how we perceive things, including colour.)


Python, signal handlers, and EINTR

One of the interesting effects of setting a signal handler inyour Python program is, well, let me quote the signal module :

  • When a signal arrives during an I/O operation, it is possiblethat the I/O operation raises an exception after the signal handlerreturns. This is dependent on the underlying Unix system's semanticsregarding interrupted system calls.

By 'an I/O operation' the manual means more than you might think; forexample, select.select() is affected by this.


由香港隊晉級國家隊的老友


今次北京之旅,最開心的,除了參加了這個博客論壇外,更開心的,是有機會和一位認識多年的老友聚舊。

我讀大學的年代(即係八、九十年代囉老友,老餅之唔係我),我邊上課邊幫大量報紙雜誌寫樂評及兼職記者,有些沒稿


北京博客論壇—「除了帽子什麽都可以綠」(二)

我慶幸當晚我臨危上陣,被點選了去作打頭陣的首位講者,因為快快完事後,接下來我便可以好好享受其他嘉賓講者的演說。

我額頭的一把汗尚未抹乾,第二位講者已經登場。孫老師是國內資深IT人,這晚,他為我們分析企業和

Continue reading...

電懋四千金


《四千金》( Our Sister Hedy, 1957), 電懋的經典作. 知道很久, 卻從沒提起興趣要看. 葉楓、林翠, 也知道名字: 一個是鄭明明好友、港姐季軍張郁蕾姨母, 一個是曾江家姐、陳山河和王韾平的母親, 卻也未看過她們的電影. (
Continue reading...