This is an old copy of the Python FAQ. The information here may be outdated.

What is used for?

Files named are used to mark directories on disk as a Python package directories. If you have the files


and mydir is on your path, you can import the code in as:

import spam.module


from spam import module

If you remove the file, Python will no longer look for submodules inside that directory, so attempts to import the module will fail.

The file is usually empty, but can be used to export selected portions of the package under more convenient names, hold convenience functions, etc. Given the example above, the contents of the __init__ module can be accessed as

import spam

CATEGORY: programming


A Django site. rendered by a django application. hosted by webfaction.