Python Package -


A regular package is typically implemented as a directory containing an file.

The file is tells Python that you can use the folder to import a module. (The default behavior is no import).

When a regular package is imported, this file is implicitly executed, and the objects it defines are bound to names in the package’s namespace.

The file can contain the same Python code that any other module can contain.

The mechanism is done to prevent directories with a common name, such as string, from unintentionally hiding valid modules that occur later on the module search path.

In the simplest case, can just be an empty file, but it can also:

  • execute initialization code for the package
  • or set the all variable


The __all__ variable define a list of module to import when using the package import * statement. See Python Package - Import It defines an explicit index of the package.


__all__ = ["echo", "surround", "reverse"]

Powered by ComboStrap