Your Linux Data Center Experts

Recently I ran across a blog post from Titus titled What are the 5 best “hidden gem” stdlib modules in Python?. Here are mine.

First, the standard library modules, in no particular order:

  • fileinput – Though I wish that it was a bit easier to deal with doing filters, the ability to easily just say “Give me all the data in the files on the command line or stdin” is very useful for processing information. Obviously, I usually combine this with the “re” module.
  • popen2 (now subprocess) – The ability to run programs and get their output, stderr, etc… This will always be popen2 to me. :-) subprocess also includes spawn(), which can take arguments as a tuple, so you don't have to worry about quoting issues.
  • glob – “print glob.glob('*.png')”. Very handy.
  • rfc822 (now email) – In particular, I really love the Message() class, where you can have it read “key: value” type blocks of input, like the header of an e-mail message. I've used this for many things including config files and input to a reminder system.
  • telnetlib – I love the expect-like abilities to read data from a remote server, wait for it to send something, respond with something else. Recently I wrote a program to interact with a remote power switch over it's native telnet interface, for example. telnetlib made that very easy.

And my favorite add-on libraries, again in no particular order:

  • pygame – Extremely easy to use, I've used it to create several image viewing and management programs, and to replicate a “speed reading training” program I wanted to try out but was available Window-only.
  • psycopg – I like Postgres, I like Python, this is the sticky goo that brings them together.
  • myghty – Now Mako. A web templating library I usually use with mod_python to make web interfaces to things. It's fast, and fairly well documented, and very flexible. I've come to really like it's syntax.
  • pyspf – This helps keep my mailbox usable, every piece of e-mail our company gets is reviewed by pyspf. I'm currently using it with the Python milter library.
  • distutils – Not setuptools. “python bdist_rpm” makes me happy. I use this all the time. The new setuptools cruelty is making me sad, because it seems to be making it harder to package in such a way that the native packaging system on the distro can handle it.
comments powered by Disqus

Join our other satisfied clients. Contact us today.