boB Stepp wrote: >> import Tkinter as tk > > Question: I have been using "from Tkinter import *" as suggested in > "Programming Python" by Lutz. He remarks that unlike other situations, > this is generally safe with Tkinter. Is there a benefit to doing the > import as you have?
It's a stylistic preference: I like to keep namespaces separate. When I make an exception, typically for generic functionality like contextmanager, groupby, namedtuple, defaultdict... I import these in a controlled way with from collections import defaultdict from itertools import islice, zip_longest etc., use them as "pseudo-builtins", and avoid writing functions with the same name myself. By contrast I have no clear idea of what's in the tkinter package and might write my own getint() function, say, thus forcing a reader to scan the complete module to learn which getint() is used. This is a general problem of star imports; when you overwrite an imported name you typically don't care or even know about that name in the imported module. When you read your module later to fix or amend something your knowledge may have grown, and you expect the imported function where the custom function is used. This confusion becomes even more likely when a second developer is involved. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor