How to use __all__ ?

Paul Rubin phr-n2003b at NOSPAMnightsong.com
Fri Feb 7 02:35:33 EST 2003


I have a module, x.py, containing

   __all__ = ('a',)
   a = 3
   b = 5

Now I run Python:

    Python 2.2 (#1, Feb 10 2002, 19:16:58) 
    [GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-98)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import x
    >>> x.a
    3
    >>> x.b
    5
    >>> x.__all__
    ('a',)

What's the story?  I thought b was supposed to be invisible, since
it doesn't appear in x's __all__ list.  Is there some other way to
get that effect?

Thanks.




More information about the Python-list mailing list