What does __all__ do in a package?

Andreas Jung andreas at andreas-jung.com
Fri Oct 18 11:48:21 EDT 2002


--On Freitag, 18. Oktober 2002 08:34 -0700 Noah <noah at noah.org> wrote:

> 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 *
>

Yes

> (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__
>

No





More information about the Python-list mailing list