PyZh

5. Github上Python开发者应该关心的Repo

作者:hit9
日期:2013-01-30
注:欢迎fork后pull request来丰富这个文章.

5.1. carbaugh/lice

lice : Generate license files for your projects

一个用来为你的项目生成许可证的工具。这下可方便了,不用手工的去修改了!

5.2. coleifer/peewee

peewee: a small, expressive orm – supports postgresql, mysql and sqlite

你在用SQLAlchemy ? 我强烈推荐你看下peewee

来看一个sample:

User.select().where(User.active == True).order_by(User.username)

一个单文件的Python ORM.相当轻巧,支持三个数据库。而且,它最讨人喜欢的是它的轻量级的语法。

5.3. docopt/docopt

docopt : Pythonic command line arguments parser, that will make you smile

用过doctest? 那来看看docopt。有时候你用py写一个命令行程序,需要接收命令行参数,看看这个例子:

"""
Usage: test.py <file> [--verbose]
"""

from docopt import docopt

print docopt(__doc__)

如果你这么执行程序:

python test.py somefile --verbose

你会得到这样的输出:

{'--verbose': True, '<file>': 'somefile'}

5.4. hhatto/autopep8

autopep8 : A tool that automatically formats Python code to conform to the PEP 8 style guide.

每个Python程序员都应该checkout的repo.自动的把你的Python代码转成符合PEP8风格的代码.

使用 -i 参数来直接修改你的 Python文件:

autopep8 -i mycode.py

5.5. kachayev/fn.py

fn.py : Functional programming in Python: implementation of missing features to enjoy FP

这是个很有趣的项目,来弥补Python在函数式编程方面没有的一些特性。来看个sample:

from fn import _
assert list(map(_ * 2, range(5))) == [0,2,4,6,8]

5.6. nose-devs/nose

nose : nose is nicer testing for python

或许nose已经不是新鲜的测试框架了,现在还有很多新的测试框架诞生,不过大家都在用它,而且似乎没要离开nose的意思。

5.7. amoffat/sh

sh : Python subprocess interface

这个库已经被津津乐道很久了。看代码:

from sh import git

git.clone("https://github.com/amoffat/sh")

是不是比 os.system 更简洁明了。

5.8. Lokaltog/powerline

如果你是个linux(or mac)下的开发者,又喜欢在终端下工作的话,你一定喜欢用powerline来美化自己的工作空间。

之前github上兴起了vim-powerline,tmux-powerline,还有powerline-bash,现在Lokaltog提供了一个统一的解决方案,只要安装这个python包,再追加些东西到配置文件就可以使用漂亮的powerline了

具体的效果请见repo : https://github.com/Lokaltog/powerline

5.9. benoitc/gunicorn

gunicorn : gunicorn ‘Green Unicorn’ is a WSGI HTTP Server for UNIX, fast clients and sleepy applications

一个Python WSGI UNIX的HTTP服务器,从Ruby的独角兽(Unicorn)项目移植。Gunicorn大致与各种Web框架兼容.

一个例子,运行你的flask app:

gunicorn myproject:app

使用起来超级简单!

5.10. faif/python-patterns

python-patterns : A collection of design patterns implemented (by other people) in python

这个repo收集了很多设计模式的python写法

5.11. gutworth/six/

six : Six is a Python 2 and 3 compatibility library

Six没有托管在Github上,而是托管在了Bitbucket上,不过这些都不是重点,重点是它的作用。

众所周知 Python 2 和 Python 3 版本的分裂给 Python 开发者们带来了很大的烦恼,为了使代码同时兼容两个版本,往往要增加大量的代码。 于是 Six 出现了。正如它的介绍所说,它是一个专门用来兼容 Python 2 和 Python 3 的库。它解决了诸如 urllib 的部分方法不兼容, str 和 bytes 类型不兼容等“知名”问题。

它的效果怎么样?pypi上单日十万以上,单月几百万的下载量足以说明了。要知道诸如 Flask 和 Django 这类知名的库,月下载量也只有几十万。

***
Fork me on GitHub