__all__ does not work?

A

AndyL

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.

170




Any ideas?

A.
 
S

skip

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
 
A

AndyL

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,149
Members
46,695
Latest member
StanleyDri

Latest Threads

Top