utility functions within a class?
John Salerno
johnjsal at NOSPAMgmail.com
Mon May 8 16:38:46 EDT 2006
Scott David Daniels wrote:
> 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
Thanks, that's what I was thinking of. So it doesn't apply to the
contents within a class, just top-level contents?
More information about the Python-list
mailing list