Skip to main content

· 2 min read

對岸的 黄毅 兄寫了一篇 "Build extensible application with egg " 參考資料,介紹 Python 的封裝格式

在 python 社區中 egg 已經是一種廣為人知的格式了。眾所周知對於 python 來說 egg 是一種用來生小蛇的東西,小蛇自然就是 python 軟件包了 (純屬瞎扯;-)。

簡單地說,egg 之於 python 正如 jar 之於 java。是一種軟件包打包的格式

想要讀懂這篇文章的關鍵在 "egg 最重要的作用是给软件包增加元数据!" 這句話.

"软件包" 大概大家還能猜得出來是什麼,不過 "元數據" 是啥?

答案是 "MetaData", Meta-Data 的意思就是資料背後的參考資料. 用在這的意思是說,這個程式的壓縮包裡,除了提供這個程式的功能外,還提供了安裝相關的資訊.

例如我在如何把蛋砸到起司商店?中指出 cheeseshop 的上傳方式,所有 cheeseshop 上的各個說明欄位都可以事先在你的 setup.py 檔案中填好,用同樣的

setup.py bdist_egg

命令來將程式包裝成 egg 檔.

· 2 min read

EasyEclipse for python

People who are used to Microsoft VisualStudio or Java IDE usually criticize that python has no good IDE to cooperate with,

I think pydev is one of good python IDE, which is based on eclipse platform. But since you try to install it, it's pretty annoying to set the eclipse and pydev run properly.

Now EasyEclipse project provide an easy install pack of Eclipse for python, it contains:

  • eclipse platform itself,

  • pydev(eclipse python support),

  • Subclipse(eclipse SVN GUI),

  • and several useful plugins installed by default.It really ease the installation and configuration of Eclipse for python.

Pydev with Turbogears

Besides that, Pydev developer recently wrote an article for Configuring Pydev to work with Turbogears

It sounds like a right time to try for pydev + TurboGears.

So I searched and installed the Eclipse for python and EasyEclipse Web tools editors for eclipse HTML/CSS editor and an Internal Web Browser.

The result? It's not much too say.... pretty good:D

Start Up

First create a pydev project, it will assign a workspace for the project. Open the console, change path to the workspace folder. Use tg-admin tool to create a TurboGears projects named "projectname" within the pydev project workspace folder.

Now the project folder will shown on eclipse Navigator panel. (you may need use right click menu-> refresh) click the start-_projectname.py tap F9, then the web server will run.

You can use the "Open Web Browser" icon which is near with the search icon to open the internal Web Browser. Type http://localhost:8080 to see the welcome page :)

Sounds good?

Configurations

Here are a little configuration tips you may intrested...

Assign the python interpretor

1. open window/preference, select pydev/interpreter-python, click top right "Add" button to select the python.exe path (windows default is C:\python24\pythonw.exe). The proper library and key words will automatically load for you to use.

Template Association

2. select General/Editors/File Association, click top right "new" button to add "*.kid" file style for kid template. Press the second "Add" button to assign the associate editors to HTML Editor(default) and Internal Web Browser.

I also found a WYSIWYG HTML editor EasyEclipse eZingBuilder, but I can't get the kid page present correctly now.

more tips are welcome

· One min read

The Zen of TurboGears, by Fred Lin

Keep simple things simple and complex things possible Give defaults while you give choices Give choices while the one obvious way depends

Make it work Make it right Make it fast

Pythonic is better than domain specific Easy configuration is clear than convention Integration counts Batteries included rocks Flexibility flow ideas into each part of code

keep data in Model and seperated logic from Template Widgets are one honking great idea -- let's do more of those!

· One min read

從 Ruby 到 Python 一文的目的是向 Ruby 語言的使用者介紹 Python 語言.

文章中標出高亮度的部份是可以修改成目標語言 (Java, PHP.... 等等) 的部份。歡迎使用相同的版型與內容,群策群力,創作一系列 "從 xxx 到 Python" 的系列介紹文章.

有問題或建議請在 Google Group 中提出

· One min read

從 C 到 Python 一文的目的是向 C 語言的使用者介紹 Python 語言.

文章中標出高亮度的部份是可以修改成目標語言 (Java, PHP.... 等等) 的部份。歡迎使用相同的版型與內容,群策群力,創作一系列 "從 xxx 到 Python" 的系列介紹文章.

有問題或建議請在 Google Group 中提出