__all__ does not work?

Discussion in 'Python' started by AndyL, May 10, 2006.

  1. AndyL

    AndyL Guest

    This a mm.py module:

    _all__=('getsize1',)

    size=85

    def getsize1():
    return size

    def getsize2():
    return 2*size


    I do not know why but getsize2 is not kept priviate?

    $ python
    Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on
    win32
    Type "help", "copyright", "credits" or "license" for more information.

    >>>>>> import mm
    >>>>>> mm.getsize2()


    170




    Any ideas?

    A.
     
    AndyL, May 10, 2006
    #1
    1. Advertising

  2. AndyL

    Guest

    Andy> This a mm.py module:
    Andy> _all__=('getsize1',)

    Andy> size=85

    Andy> def getsize1():
    Andy> return size

    Andy> def getsize2():
    Andy> return 2*size


    Andy> I do not know why but getsize2 is not kept priviate?

    That's not what __all__ is used for. Try this:

    from mm import *

    The only name added to your namespace will be getsize1.

    Skip
     
    , May 10, 2006
    #2
    1. Advertising

  3. AndyL

    AndyL Guest

    wrote:
    > Andy> This a mm.py module:
    > Andy> _all__=('getsize1',)
    >
    > Andy> size=85
    >
    > Andy> def getsize1():
    > Andy> return size
    >
    > Andy> def getsize2():
    > Andy> return 2*size
    >
    >
    > Andy> I do not know why but getsize2 is not kept priviate?
    >
    > That's not what __all__ is used for. Try this:
    >
    > from mm import *
    >
    > The only name added to your namespace will be getsize1.
    >
    > Skip


    Okay, got it. Thx.
     
    AndyL, May 10, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. TB
    Replies:
    2
    Views:
    3,772
  2. Vineet Jain
    Replies:
    9
    Views:
    462
    Fredrik Lundh
    Apr 16, 2004
  3. Karim
    Replies:
    6
    Views:
    404
    OKB (not okblacke)
    Jul 29, 2011
  4. Ethan Furman

    __all__

    Ethan Furman, Aug 9, 2011, in forum: Python
    Replies:
    1
    Views:
    364
    Steven D'Aprano
    Aug 9, 2011
  5. Phi!
    Replies:
    1
    Views:
    200
Loading...

Share This Page