[Tutor] Question on "import foobar" vs "from foobar import *"

Kent Johnson kent37 at tds.net
Mon Jan 11 03:34:36 CET 2010


On Sat, Jan 9, 2010 at 3:50 AM, spir <denis.spir at free.fr> wrote:
> Lie Ryan dixit:
>
>> only use "from module import *" if the
>> module was designed for such use
>
> In most cases, this translates to: the imported module defines __names__, which holds the list of names (of the objects) to be exported. Check it.
> Below, a,b,c,f,g,X,Y are defined, but only c,g,Y are exported. This means "from mod import *" will only import these names. Without __names__ defined, it would import all.\

That should be __all__, not __names__

Kent


More information about the Tutor mailing list