The Python Standard Library has a lot of modules! To help you get familiar with what's available, here are a selection of our favourite Python Standard Library modules and why we use them!
-
csv: very convenient for reading and writing csv files -
collections: useful extensions of the usual data types includingOrderedDict,defaultdictandnamedtuple -
random: generates pseudo-random numbers, shuffles sequences randomly and chooses random items -
string: more functions on strings. This module also contains useful collections of letters likestring.digits(a string containing all characters with are valid digits). -
re: pattern-matching in strings via regular expressions -
math: some standard mathematical functions -
os: interacting with operating systems -
os.path: submodule ofosfor manipulating path names -
sys: work directly with the Python interpreter -
json: good for reading and writing json files (good for web work)
How to import:
from module_name import object_name as different_name
for example:
from csv import reader as csvreader