Skip to main content

python 禪學

· 2 min read

任何安裝好的 python 版本中都包含著 python 禪學 (哲學), 在任何 python 互動介面 (如 IDLE) 中輸入

import this

則會出現如下的 python 禪學 (哲學)

Python 禪學 (pythoon Zen)

美觀的比醜陋的好 (Beautiful is better than ugly) 直率的比含糊的好 (Explicit is better than implicit) 簡單的比繁雜的好 (Simple is better than complex) 繁雜的比晦澀的好 (Complex is better than complicated) 平直的比巢雜的好 (Flat is better than nested) 疏落有致的比櫛次鱗比的好 (Sparse is better than dense) 可讀性應當被重視 (Readability counts)

就算是特例,也不能壞了規矩 (Special cases aren't special enough to break the rules) 然而能解決問題仍然比維持單純重要 (Although practicality beats purity)

錯誤不應該被默默地放過 (Errors should never pass silently) 除非你是刻意為之 (Unless explicitly silenced)

面對模稜兩可的情況,要抗拒猜測的誘惑 (In the face of ambiguity, refuse the temptation to guess) 應該會有一個 -- 而且最好只有一個 -- 適當的方式來實現 (There should be one-- and preferably only one --obvious way to do it) 雖然不是這個語言創造者的妳一開始可能看不出來 (Although that way may not be obvious at first unless you're Dutch)

現在動手比總是不動手的好 (Now is better than never) 然而不動手可能還比沒有準備就動手的好 (Although never is often better than right now)

如果實作方式難以解釋,那大概是個壞主意 (If the implementation is hard to explain, it's a bad idea) 如果實作方式易於解釋,那可能是個好主意 (If the implementation is easy to explain, it may be a good idea) 名稱空間是一個很棒的主意 -- 我們就盡量用吧!(Namespaces are one honking great idea -- let's do more of those!)

--Tim Peters (gasolin 翻譯)

2007/03/01 更新: 參考 http://wiki.python.org.tw/The_Zen_Of_Python 其他人的理解修改

示範影片: 使用 TurboGears 製作書站

· One min read

前幾個禮拜看到 limodou 的 Openbook platform 後弄的 TurboGears 製作書站 screencast (示範影片)

第一個影片裡示範了如何使用 TurboGears 建立一個專案,與如何啟動開發用網頁伺服器. 並展示了如何透過修改模板快速訂製頁面。這個 screencast 中完全使用 TurboGears 預設的 CSS style.

1st. is a quickstart demo with hello world template version (6.5MB)

第二個影片裡示範了如何使用 TurboGears 工具箱 (Toolbox) 中的模型設計工具 (Model Designer)和資料編輯工具 (Catwalk) 來建置 TurboGears 動態內容網站

2nd is Model Designer with Catwalk (7.7MB)

第三個影片中使用到我寫的 TurboGears tgcrud 擴充模組,透過 tgcrud 擴充模組可以很容易地產生類似 Rails 的 scaffold 介面架構。但與 scaffold 不同的是所有 code 都是 implicit 的,更加容易修改.

3rd. is tgcrud, the TG's scaffold (5.2 MB)

感謝 Elvelind Grandin 協助上傳至 TurboGears 網頁空間.

Python 網頁框架出新招, KUSO 圖徵求貢獻文件

· One min read

晚上剛看到在 TurboGears 的說明文件寫作文件中加上了張圖

這張圖上的口號是:

Onward, Documentation Writers! DID YOU CONTRIBUTE SOMETHING TODAY?

可以翻譯成:

前進吧,(寫手) 同志們 你今天為 (TurboGears 的文件) 革命事業貢獻了些什麼嗎?

TurboGears 用這麼有趣的圖 (萬里大長征) 來徵求貢獻文件,真是很 KUSO 呀...

PS: 這週末 (2/10) 有近期的第二次 TurboGears Doc Sprint 喔.