Common Python Libraries

In my day job at the BBC, we use Python. It’s a great scripting language; highly versatile, well supported and mixes simplicity with complexity, if need be.

One of the challenges of my day job to date, has been learning AWS, Ruby and Python as I go. This presents challenges as it’s not easy to adequately take in and absorb all the information thrown at you. Particularly when a language has its own ecosystem and SDK to learn.

Like Java, Python has its own standard modules. Here’s a few modules that are commonly used in most scripting applications.

import os

The OS module provides lots of very useful classes and methods that allow developers to interact with the operating system. For instance, we can execute bash commands using the os.system(“echo ‘hello'”) method to list, create, delete and modify directories. Alternatively, you can use the shutil module instead, which provides a higher level of abstraction from os.

import math

The math module is also very useful…

import re

The re module is a confusing name given its purpose. It is useful for pattern matching using regular expressions (Regex).

import urllib2

The urllib2 module is very useful for when you need to interact with the internet. It’s useful for creating HTTP clients and sending requests to external web services using REST.

from datetime import date

The datetime module…

import zlib

The zlib module is used for data compression. It supports data compression across .zip, .tar.gz, etc. Pretty cool.

Summary

import os
import shutil # higher abstraction from os
import math
import re
import urllib2
from datetime import date
import zlib

This entry was posted in Python, Software Engineering. Bookmark the permalink. Follow any comments here with the RSS feed for this post. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>