This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients serhiy.storchaka, terry.reedy
Date 2017-02-04.21:24:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1486243465.34.0.0929989866435.issue29446@psf.upfronthosting.co.za>
In-reply-to
Content
Tkinter naming was designed so that 'from tkinter import *' can work, in the sense of not conflicting with built-in and stdlib module names.  But there are currently two problems.

1. The current doc

...to use Tkinter all you need is a simple import statement:
  import tkinter
Or, more often:
  from tkinter import * 

over-promotes 'import *' as the common and therefore normal import (as opposed to a convenience for interactive use).  It neglects the alternatives 'import tkinter as tk' or 'from tkinter import Tk, ...', and consequently makes no mention of the relative advantages.

2. The current code does not define __all__.  So the stdlib imports of enum, re, and sys get carried over with 'import *'.  Guido recommends defining __all__ to prevent this.*  Since tkinter defines about 160 names, and since there are only 3 names to block, and there are used pretty sparingly, I prefer the uglier alternative of renaming with underscores: 'import enum as _enum', etc.

I will work on patches.  Since the doc change can apply to all current versions while the code change might be restricted to 3.7, I will keep then separate.


* From pydev thread 'Imports with underscores', 2017-1-9:

"I would focus on changing habits to discourage "import *" rather than
uglifying all new code with this "os as _os" pattern. Very occasionally
one designs a module to explicitly support "import *", and that usually
entails using __all__ (like it or not), making the problem go away
without uglifying the code."
History
Date User Action Args
2017-02-04 21:24:25terry.reedysetrecipients: + terry.reedy, serhiy.storchaka
2017-02-04 21:24:25terry.reedysetmessageid: <1486243465.34.0.0929989866435.issue29446@psf.upfronthosting.co.za>
2017-02-04 21:24:25terry.reedylinkissue29446 messages
2017-02-04 21:24:24terry.reedycreate