I thought I understood this, but apparently not:
Under py3:

1. "import tkinter" imports the whole module into the name space. Any access to names therein must be prefixed with the module name.
ie top = tkinter.Tk()
But tkinter.messagebox.showwarning() errors with "module has no attribute 'messagebox'"

2. "from tkinter import *" loads the name space from the module into the program name space. No need to prefix the module name onto the attribute name. Pollutes the name space, but makes typing easier.
ie top = Tk()
But messagebox.showwarning() still errors.

3. in either of the above cases, if I add "from tkinter import messagebox, the attribute resolves correctly.

I imagined that the "*" form implied "load the lot". Evidently, my understanding is lacking. Will somebody please put me straight, or give me a reference to some definitive documentation?

--
Tony van der Hoff        | mailto:t...@vanderhoff.org
Buckinghamshire, England |
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to