Lozansky
Lozansky

Reputation: 374

What exactly does " from module import * " mean?

I thought it meant everything in the module. But in tkinter I would have to specifically import things like messagebox, colorchooser and filedialog despite having a "from tkinter import *" command. So exactly what does "import *" mean?

Upvotes: 1

Views: 12039

Answers (3)

acdr
acdr

Reputation: 4716

A module can define an __all__ variable: a list containing the names that will be imported when you do from module import *. Anything not in this list will not actually be imported. https://docs.python.org/2/tutorial/modules.html

Upvotes: 6

János Farkas
János Farkas

Reputation: 471

from module import *

This imports all names except those beginning with an underscore (_).

read more: Python modules

Upvotes: -3

Zafi
Zafi

Reputation: 629

It just means that you import all(methods, variables,...) in a way so you don't need to prefix them when using them.

Upvotes: -1

Related Questions