home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
utilities
/
p
/
python
/
pyhtmldoc
/
m
/
modules
< prev
next >
Wrap
Text File
|
1996-11-14
|
1KB
|
25 lines
<TITLE>Modules -- Python library reference</TITLE>
Next: <A HREF="../c/classes_and_instances" TYPE="Next">Classes and Instances</A>
Prev: <A HREF="../o/other_built-in_types" TYPE="Prev">Other Built-in Types</A>
Up: <A HREF="../o/other_built-in_types" TYPE="Up">Other Built-in Types</A>
Top: <A HREF="../t/top" TYPE="Top">Top</A>
<H3>2.1.7.1. Modules</H3>
The only special operation on a module is attribute access:
<CODE><VAR>m</VAR>.<VAR>name</VAR></CODE>, where <VAR>m</VAR> is a module and <VAR>name</VAR> accesses
a name defined in <VAR>m</VAR>'s symbol table. Module attributes can be
assigned to. (Note that the <CODE>import</CODE> statement is not, strictly
spoken, an operation on a module object; <CODE>import <VAR>foo</VAR></CODE> does not
require a module object named <VAR>foo</VAR> to exist, rather it requires
an (external) <I>definition</I> for a module named <VAR>foo</VAR>
somewhere.)
<P>
A special member of every module is <CODE>__dict__</CODE>.
This is the dictionary containing the module's symbol table.
Modifying this dictionary will actually change the module's symbol
table, but direct assignment to the <CODE>__dict__</CODE> attribute is not
possible (i.e., you can write <CODE><VAR>m</VAR>.__dict__['a'] = 1</CODE>, which
defines <CODE><VAR>m</VAR>.a</CODE> to be <CODE>1</CODE>, but you can't write <CODE><VAR>m</VAR>.__dict__ = {}</CODE>.
<P>
Modules are written like this: <CODE><module 'sys'></CODE>.
<P>