cover

best practice

code style

  • encoding
  • pep8
  • linter, flake8

package

  • pip
  • virturalenv
  • setup.py

http://lingxiankong.github.io/blog/2013/12/23/python-setup/

testing

  • pytest
  • mock
  • tox

py2 py3

from __future__ import unicode_literals
from __future__ import absolute_import
  • six

https://pythonhosted.org/six/
http://woodpecker.org.cn/diveintopython3/porting-code-to-python-3-with-2to3.html

data structures

  • list
  • dict
  • set
  • tuple

Looping

built-in functions

  • list dict set tuple sorted
  • range enumerate zip
  • all any
  • type id
  • dir getattr setattr

Exception

  • try except
  • Look Before You Leap
  • Easier to ask forgiveness than permission

decorater

  • decorater
  • functools.wraps
  • functools.partial

library

  • datetime, date, time, dateutil
  • json

module

  • from xx import *
  • relative import
  • absolute import

flask

  • request response
  • context
  • read the source code

相关学习资源

https://github.com/wklken/stackoverflow-py-top-qa
http://pyzh.readthedocs.org/en/latest/index.html
http://xianglong.me/article/how-to-code-like-a-pythonista-idiomatic-python

博客

http://www.pythoner.com/
http://blog.xiayf.cn/
http://wklken.me/

扫描二维码,分享此文章

guyskk