Chapter 3. Interacting with the world

 

This chapter covers

  • What libraries are
  • How to use libraries, including Python’s standard library
  • An example program that uses Python’s os and sys libraries
  • Python’s dictionary data type

One of the key strengths of Python is its standard library. Installed along with Python, the standard library is a large suite of program code that covers common tasks like finding and iterating over files, handling user input, downloading and parsing pages from the web, and accessing databases. If you make good use of the standard library, you can often write programs in a fraction of the time that it would take you otherwise, with less typing and far fewer bugs.

Guido’s Time Machine

The standard library is so extensive that one of the running jokes in the Python community is that Guido (the inventor of Python) owns a time machine. When someone asks for a module that performs a particular task, Guido hops in his time machine, travels back to the beginning of Python, and— “poof!”—it’s already there.

“Batteries included”: Python’s libraries

 
 
 

Another way to ask questions

 
 
 

Reading and writing files

 
 

Comparing files

 
 
 

Putting it all together

 
 
 

Testing your program

 

Improving your script

 

Where to from here?

 
 

Summary

 
 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest