Identifiers exposed by a package (was: How to import only one module in a package when the package __init__.py has already imports the modules?)

Ben Finney ben+python at benfinney.id.au
Sun Nov 1 01:54:12 EDT 2009


Robert Kern <robert.kern at gmail.com> writes:

> If you are going to expose symbols in your __init__.py, they should
> not have the same name as any of the modules in the package.

Would I be correct in assuming you make an exception for the package
importing one of the modules in the package, and thereby making that
module's identifier exposed?

    package_foo/
        __init__.py
        module_bar.py

    $ cat foo/__init__.py
    import module_bar

Now the name ‘package_foo.module_bar’ will get the identifier already
assigned within ‘package_foo/__init__.py’, but that identifier is the
module anyway.

-- 
 \         “We demand rigidly defined areas of doubt and uncertainty!” |
  `\    —Vroomfondel, _The Hitch-Hiker's Guide To The Galaxy_, Douglas |
_o__)                                                            Adams |
Ben Finney



More information about the Python-list mailing list