Go 號稱可以寫得和 Python 一樣快,又跑得和 C 一樣快。簡直就是一隻不會吃草的馬。

有空要來試試看,至少陣列看起來有點用,不像 C 那麼彆腳。

Posted by yungyuc at 08:29, 1 comments, 0 trackback.

The original SCons CUDA tool is a little bit out-dated, and mal-functioning. As a by product in my coding, I made some improvement over it.

The major improvement is instead of adding .linkinfo in the emitter, I add cleaning dependency for automatic removing the generated .linkinfo. This allows user to use env.SharedObject with env.SharedLibrary (and also static ones).

The following is the modified CUDA tool. To use it, save the text into the file named cuda.py, and place it in site_scons\site_tools relative to your SConstruct/SConscipt.

» continue reading
Posted by yungyuc at 06:36, 0 comment, 0 trackback.
tag on Google Python

yagt 不是 yet another google trends tool,而是 Y's API for Google Trends

動機有點複雜,但程式很簡單、功能很簡單、安裝也很簡單。我在 Python 2.5/2.6 下都測過,只要 easy_install -UZ yagt 即可安裝。裝好之後,用 python2.6 -m  yagt 就可以 invoke 指令行介面。如果沒有用 -u username 指定使用者名稱,程式會用 rawinput() 詢問;密碼則是一定用問的。

用 yagt 就可以直接在命令列把 Google Trends 的資料存成 csv 檔。中文也通。不過 Google 擋 bot 擋很兇的樣子,一不小心抓太爽的話,很容易被 Google 把你的 IP 擋掉喔。我還在等 Google unblock 我 ... :'(

Posted by yungyuc at 10:36, 0 comment, 0 trackback.
<kcwu> how about your opinion to add CNS11643 into python?
# http://bugs.python.org/issue2066
<y5c> 問題是:誰會用?
<y5c> 實務上大家都要轉用 UTF-8 了,
目前我唯一可以想到的用戶是圖書館員?

某個去年的老 issue 在 BTS 上被 revive 了回來。如果不是 kcwu 在頻道上問,大概誰也不會想起來 CNS11643 這個東西。Python 的中文使用者要好好感謝來自韓國的 Hye-Shik Chang。如果沒有他的付出,大家都得用彆腳的 Python。

» continue reading
Posted by yungyuc at 22:53, 1 comments, 0 trackback.

最近在 ptt 和 python.tw@ggroup 上看到一些關於 Python 下 Unicode 的討論,發現很多人在寫 Python 的時候,遇到 non-ASCII 字元就頭痛。Python 的 Unicode 支援非常直接易懂,透過 unicode 物件,non-ASCII 字元可以處理得非常漂亮。Python 程式員很幸福,標準程式庫已經把工具排在那裡,用就好了。

在 Python 中對 non-ASCII 字元的處理,大概可以分成兩類:

  1. 原始碼的編碼。
  2. non-ASCII 資料。

通常會遇到 1. 的問題,就是因為想對付 2. non-ASCII 資料。不過在 Python 原始碼檔案裡一旦出現了 non-ASCII 字元,就有多一點地方要注意。

» continue reading
Posted by yungyuc at 04:32, 0 comment, 0 trackback.

世理是拳頭力量大。當我拳頭小的時候,不是很喜歡這樣。

ISO 3166 是定義國家/獨立地理區的國際標準。不過它很討人

討厭歸討厭,如果想要一份「正確的」國家列表,它大概是最容易拿到的資料;我們常用的 TW, CN, US 等雙字母國別代碼是編在 ISO 3166 的 alpha-2 表裡面。

在 Python 下有 pycountry 替 ISO 3166 實作了一份 mapping。pycountry 內部存了一組 XML-based 的資料庫,在被 import 的時候會 on-demand 載入這份資料庫,然後生成一份 iterable mapping-like 的物件,當作這些資料的模型。除了 ISO 3166 之外,pycountry 還包裝了 ISO 639 語言代碼表,以及 ISO 4217、ISO 15924。

» continue reading
Posted by yungyuc at 07:30, 0 comment, 0 trackback.
Django 1.0
tag on Django Python

Django framework 1.0 released!

雖然我一路 SVN 跑上來,又沒花時間追 mailing list,所以沒什麼真實感,不過在此一賀!相關報導請參閱偉大提姆的文章

Posted by yungyuc at 06:03, 0 comment, 0 trackback.

重灌了 XP,拿掉了 TortoiseHg,又拿掉了 TortoiseSVN。

» continue reading
Posted by yungyuc at 11:18, 0 comment, 0 trackback.

這篇文章寫於兩年前,主題鎖定在以 Python 寫 Linux 的 script。討論了 Python script 的慣用寫法、字串處理、字元編碼、檔案與目錄處理、呼叫外部程式,以及利用內建程式庫進行網路通訊。

» continue reading
Posted by yungyuc at 06:35, 1 comments, 0 trackback.

據說裡面是 Django,不過註冊有人數限制,現在只好先 K API 過過癮...

Posted by yungyuc at 19:24, 5 comments, 0 trackback.
Change to page (10 entries in each page): 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
© hover year to navigate month: powered by django