help on "from deen import *" vs. "import deen"
jfong at ms4.hinet.net
jfong at ms4.hinet.net
Wed Nov 16 20:54:05 EST 2016
Steve D'Aprano at 2016/11/16 8:33:23AM wrote:
> `import foo` imports the module foo, that is all. (To be pedantic: it is
> *nominally* a module. By design, it could be any object at all.)
>
> `from foo import *` imports all the visible public attributes of foo.
>
> They do completely different things, equivalent to something similar to:
>
> five = int('5')
>
>
> versus:
>
>
> _tmp = int('5')
> for name in dir(_tmp):
> if not name.startswith('_'):
> locals()[name] = getattr(_tmp, name)
> del _tmp
This is far beyond my comprehension:-(
--Jach
More information about the Python-list
mailing list