What does __all__ do in a package?

Noah noah at noah.org
Fri Oct 18 17:34:56 CEST 2002


I'm designing a module. I want to make sure that I
am using __all__ properly.

This is how I understand the __all__ variable --
Someone please tell me if I am wrong or right:
__all__ is a list of strings that limit what is
exported by a package when you use:
   from MyPackage import *

(Kind of reminds me of extern in C++)

Does __all__ also limit what is visible if I reference
the package by name? For example:

import MyPackage
print MyPackage.my_variable_not_listed_in__all__


Yours,
Noah



More information about the Python-list mailing list