Alex Rivera | Logout

What exactly does "import *" import?

Asked 2010-03-02T03:31:45.157
74

In Python, what exactly does import * import? Does it import __init__.py found in the containing folder?

For example, is it necessary to declare from project.model import __init__, or is from project.model import * sufficient?

Edit
Report

1 Answer

2

If the module in question (project.model in your case) has defined a list of stings named __all__, then every named variable in that list is imported. If there is no such variable, it imports everything.

answered 2010-03-02T03:43:20.243

Your Answer