Chapter 5. Modules

Chapter 5. Modules

This chapter presents the Python module ”the highest-level program organization unit, which packages program code and data for reuse. In concrete terms, modules take the form of Python program files (and C extensions); clients import modules to use the names they define. Modules are processed with two new statements and one important built-in function we explore here:

import

Lets a client fetch a module as a whole

from

Allows clients to fetch particular names from a module

reload

Provides a way to reload a module's code without stopping Python

We introduced module basics in Chapter 1, and you may have been using module files in the exercises, so some of this chapter may be a review. But we also flesh out module details we've omitted so far: reloads , module compilation semantics, and so on. Because modules and classes are really just glorified namespaces , we explore namespace basics here as well, so be sure to read most of this chapter before tackling the next .



Learning Python
Learning Python: Powerful Object-Oriented Programming
ISBN: 0596158068
EAN: 2147483647
Year: 1999
Pages: 156
Authors: Mark Lutz

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net