utility functions within a class?

Scott David Daniels scott.daniels at acm.org
Mon May 8 16:13:46 EDT 2006


John Salerno wrote:
> Dennis Lee Bieber wrote:
>> ...   Single underscores are a convention/signal to the programmer that
>> "this method/attribute" is considered "private" and should only be used
>> by other methods within the class that defined it. The language does no
>> enforcement of usage....
> 
> I see. But isn't there something about a single leading underscore that 
> doesn't import when you use from X import *? Or am I thinking of 
> something else? Is that also the double underscore?

That has to do with module contents, and is a completely separate issue.
If you define a module with a variable name '__all__' which is a list
(or tuple) of strings, only module elements with those names will be
imported with a "from module import *".  If you fail to define the
'__all__' element, all names which do not start with an underscore will
be imported.

--Scott David Daniels
scott.daniels at acm.org



More information about the Python-list mailing list