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 filescollections
: useful extensions of the usual data types includingOrderedDict
,defaultdict
andnamedtuple
random
: generates pseudo-random numbers, shuffles sequences randomly and chooses random itemsstring
: 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 expressionsmath
: some standard mathematical functionsos
: interacting with operating systemsos.path
: submodule ofos
for manipulating path namessys
: work directly with the Python interpreterjson
: 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