469,903 Members | 2,056 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,903 developers. It's quick & easy.

public and private members of the module

Acording to documentation the are 2 ways to "hide" functions, data
inside the module:

1. __all__ list
2. starting "hiden" names with underscore.

None of these methods does not work:

############################################
#File: foo.py
import sys
__all__ = ['B']
def A():
print "In A"
def B():
print "In B"
def _C():
print "In _C"
############################################
#File: a.py
import foo
print dir(foo)
foo.A()
foo.B()
foo._C()

Running a.py produces this output:

['A', 'B', '_C', '__all__', '__builtins__', '__doc__', '__file__',
'__name__', 'sys']
In A
In B
In _C

Can somebody explain this?

I'm working on Windows Python 2.3
Thanks in advance
Jul 18 '05 #1
2 1382
On 23 Jun 2004 21:45:07 -0700, el*******@hotmail.com (Lev Elblert)
declaimed the following in comp.lang.python:
Acording to documentation the are 2 ways to "hide" functions, data
inside the module:

1. __all__ list
2. starting "hiden" names with underscore.

None of these methods does not work:
Forgive me, but your double negative phrase is equal to "all of
these methods do work" <G>

And, they probably do... What you missed is that the "hide" only
applies to the use of

from module import *

The * will only pick up those in the __all__ list, or in on
__all__ then those not beginning with _

-- ================================================== ============ <
wl*****@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG <
wu******@dm.net | Bestiaria Support Staff <
================================================== ============ <
Home Page: <http://www.dm.net/~wulfraed/> <
Overflow Page: <http://wlfraed.home.netcom.com/> <

Jul 18 '05 #2
On Thu, 24 Jun 2004 05:07:05 GMT, Dennis Lee Bieber
<wl*****@ix.netcom.com> declaimed the following in comp.lang.python:

The * will only pick up those in the __all__ list, or in on
Pardon -- "in on" is supposed to be "if no"
__all__ then those not beginning with _

Obviously it was time for me to go to bed...

-- ================================================== ============ <
wl*****@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG <
wu******@dm.net | Bestiaria Support Staff <
================================================== ============ <
Home Page: <http://www.dm.net/~wulfraed/> <
Overflow Page: <http://wlfraed.home.netcom.com/> <

Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Elbert Lev | last post: by
6 posts views Thread by Chris Mantoulidis | last post: by
3 posts views Thread by Joe Fromm | last post: by
3 posts views Thread by patang | last post: by
7 posts views Thread by Steve Mauldin | last post: by
11 posts views Thread by prefersgolfing | last post: by
5 posts views Thread by Paul | last post: by
86 posts views Thread by jopperdepopper | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.