Monday, November 14, 2016

寫 python 用的環境配置

大概是因為前陣子寫 golang 時,受到 golang 的啟發後,再也回不去了。最近又開始寫一些 python ,馬上就覺得好像少了一些什麼東西?

仔細一想,原來少了跟 vim 搭配的 style checker plugin 。於是我立刻找了兩套來安裝。兩套都用看看,才知道哪一套比較順手。一套是 autopep8 對應的 vim plugin,另一套是 flake8 對應的 vim plugin 。前者檢查略鬆。後者檢查比較緊,但是只差一些些而已。

另外,還有一個很重要的,是 vim plugin 無法解決的。變數、類別取名的規範。這個只能靠頭腦去記了。

Guidelines derived from Guido's Recommendations
TypePublicInternal
Packageslower_with_under
Moduleslower_with_under_lower_with_under
ClassesCapWords_CapWords
ExceptionsCapWords
Functionslower_with_under()_lower_with_under()
Global/Class ConstantsCAPS_WITH_UNDER_CAPS_WITH_UNDER
Global/Class Variableslower_with_under_lower_with_under
Instance Variableslower_with_under_lower_with_under (protected) or __lower_with_under (private)
Method Nameslower_with_under()_lower_with_under() (protected) or __lower_with_under() (private)
Function/Method Parameterslower_with_under
Local Variableslower_with_under