utility functions within a class?
Scott David Daniels
scott.daniels at acm.org
Mon May 8 19:59:15 EDT 2006
John Salerno wrote:
> Scott David Daniels wrote:
>> John Salerno wrote:
>>> ... 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.
>
> Thanks, that's what I was thinking of. So it doesn't apply to the
> contents within a class, just top-level contents?
Precisely, a "from ... import *" only creates a bunch of names bound to
a module's top-level contents (at the time of execution of the
"from ... import *"), and does not affect anything about those bound
values (except, of course, the refcount).
--
-Scott David Daniels
scott.daniels at acm.org
More information about the Python-list
mailing list