faqts : Computers : Programming : Languages : Python : Language and Syntax

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

11 of 11 people (100%) answered Yes
Recently 5 of 5 people (100%) answered Yes

Entry

What is the difference between 'import Tkinter' and 'from Tkinter import *'?

Jul 29th, 2000 20:21
unknown unknown, richard_chamberlain


If you use the from <something> import <something or *> it imports the
contents into the current namespace.
For instance if you use:
from Tkinter import *
you can use Label or Button directly,
However, if you use import Tkinter you would have to use Tkinter.Label 
or Tkinter.Button.
It is considered fairly poor practice to use from * import because 
you're bringing everything into the current namespace. One of the 
exceptions to this is GUI programming  (i.e. Tkinter or whatever) 
because the names used are fairly obviously GUI related 
(Button,Widget,Canvas,etc.)