module confusion
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Fri Oct 5 07:00:37 EDT 2007
On Fri, 05 Oct 2007 00:12:33 -0500, Robert Kern wrote:
> This is somewhat odd, because most modules aren't exposed that way. They
> are either in their own file and accessed by importing them directly, or
> they are inside a package.
Any time you say:
import parrot
in one of your modules, you export parrot to anything that imports your
module. (Unless you take specific steps to prevent it, for instance with
del parrot.)
Just to pick some random examples:
>>> import ConfigParser, base64, fileinput
>>> ConfigParser.re
<module 're' from '/usr/lib/python2.5/re.pyc'>
>>> base64.struct
<module 'struct' from '/usr/lib/python2.5/struct.pyc'>
>>> base64.binascii
<module 'binascii' from '/usr/lib/python2.5/lib-dynload/binascii.so'>
>>> fileinput.sys
<module 'sys' (built-in)>
>>> fileinput.os
<module 'os' from '/usr/lib/python2.5/os.pyc'>
It's quite common.
--
Steven.
More information about the Python-list
mailing list