Pages

Wednesday, 25 December 2013

python-modules-you-should-know

原文链接:http://tmp.devcharm.com/pages/python-modules-you-should-know

Python is beautiful. So keep your code clean and maintainable with those modules.
  •  Docopt. Forget optparse and argparse, and build beautiful, readable and (if you need) complex command-line interfaces using docstrings. IMO the best module created in 2013.
  •  Requests, or HTTP for humans, is a more pythonic approach to deal with HTTP requests. Much, much, much better than urllib2. And it has been downloaded over 5,000,000 times from PyPI for a reason 
  •  lxml is a binding for libxml2 and libxslt. If you are dealing with XML or HMTL, lxml is the best solution. Full stop.
  •  Bottle is a fast, simple and lightweight WSGI micro web-framework. Build small websites and REST APIs in seconds. All the framework is just one py file that you can drop in your directory.
  •  sh is a full-fledged subprocess interface for Python that allows you to call any program as if it were a function. Super handy.
  •  Structlog is advanced processor for logging. It integrates with any existing logger, wrapping the Python standard library. You can build custom loggers, adding context as you go, to keep your logs consistent and readable.
  •  Watchdog is cross platform Python library and shell utilities to monitor file system events. Super handy and easy to use.
  •  Delorean lets you play with dates and times in a very convenient way. Set time zones, truncate to seconds, minutes, hours, or even iterate from one date to another using a specific step. Check out the doc, it contains plenty of examples.