Most useful Python modules from the standard library? [closed]
I am teaching a graduate level Python class at the University of Paris, and the students need to be introduced to the standard library. I want to discuss with them about some of the most important standard modules.
What modules do you think are absolute musts? Even though responses probably vary depending on your field (web programming, science, etc.), I feel that some modules are commonly needed: math
, sys
, re
, os
, os.path
, logging
,… and maybe: collections
, struct
,…
What modules would you suggest I present, in a 1 or 2 hour slot?
Solution 1:
Modules to cover in a 1-2 hour slot entirely depend on your audience's interest or focus. What other classes are they taking? What are they prepared to make use of immediately?
Be sure to mention math
, decimal
and datetime
and time
and re
.
For IT-types who will be doing file-oriented work: glob
, fnmatch
, os
, os.path
, tempfile
, and shutil
.
Database folks must hear about sqlite
and json
.
Simulation audience may want to hear about random
.
Web developers must hear about urllib2
from a client point of view. Also Beautiful Soup and an XML parser of your choice.
Web developers must hear about logging
and wsgiref
from a server point of view.
Solution 2:
I'd offer itertools
and functools
. These modules operate over abstractions that are found everywhere in programming, so I think they are useful to study. Among more practical things, xml modules (xml.dom
, xml.sax
) can be very useful.
Solution 3:
Have a look at PyMOTW (Python Module Of The Week). Although it is not strictly stdlib, it's a great resource of obvious and not so obvious gems of the python stdlib. What's more, it also serves as excellent documentation of the introduced modules.