473,378 Members | 1,422 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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 1461
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Elbert Lev | last post by:
Hi, all! In accordance with Python documentation, there are 2 ways to hide data/methods inside the module (make them private): 1. have "public" members defined in __all__ list 2. start...
6
by: Chris Mantoulidis | last post by:
Forgive me if I'm wrong but I think there is something like an extra member scope in classes. for example: class abc { ostream & operator << (ostream &, const abc &); istream & operator >>...
19
by: qazmlp | last post by:
class base { // other members public: virtual ~base() { } virtual void virtualMethod1()=0 ; virtual void virtualMethod2()=0 ; virtual void virtualMethod3()=0 ;
3
by: Joe Fromm | last post by:
Perhaps I'm missing something obvious, but I've been curious about one of the coding practices I see advocated. I'm a longtime C/C++ programmer trying to learn C#, and I started looking around for...
3
by: patang | last post by:
Very simple question. I have a project with multiple forms and a Module1. In Module1 I have written the connectionstring: Module Module1 Public connectionstring =...
7
by: Steve Mauldin | last post by:
I have a public variable that is declared in a public module. This Variable is stored into a Session variable and used to pass data from page to page. I am seeing on my local development box that...
11
by: prefersgolfing | last post by:
I'm trying to find on MSDN, or someplace, that speaks to variables being public or private by default. Anyone know where? Thanks.
5
by: Paul | last post by:
Hello All, I am new to C# and dot NET in general. The book I am reading uses the term "non-public." I suspect that they don't mean "private", otherwise they would have said so. What is the...
9
by: Rudy | last post by:
Hello All! I'm a little confused on Public Class or Modules. Say I have a this on form "A" Public Sub Subtract() Dim Invoice As Decimal Dim Wage As Decimal Static PO As Decimal Invoice =...
86
by: jopperdepopper | last post by:
Hi, finally giving php 5 a go, and going over the new approach to classes. Can someone clarify the public, private and protected to me? I quote the php manual: "The visibility of a property or...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.