Alex Kleider <aklei...@sonic.net> writes: > On 2015-12-18 14:13, Mark Lawrence wrote: > > On 18/12/2015 18:38, Alex Kleider wrote: > > >> […] uses a syntax that is strongly discouraged
Yes. It is discouraged in PEP 8 and in other guides for Pythonic code. Wildcard imports ( from <module> import * ) should be avoided, as they make it unclear which names are present in the namespace, confusing both readers and many automated tools. <URL:https://www.python.org/dev/peps/pep-0008/#id17> For all new Python code, that should IMO be strongly enforced. > >> so my inclination is to use > >> import tkinter as tk > >> from tkinter import ttk > >> instead. > >> > >> Comments? I agree with that usage. ‘import inconvenientlongname as shortname’ is excellent code that combines the virtues of being explicit, concise, readable, and easily-introspected. > > from xyz import * is The Road To Hell. > > Vindicated! Note that the Python standard library documentation for Tkinter explicitly contradicts PEP 8 advice: […] usually, to use Tkinter all you need is a simple import statement: import tkinter Or, more often: from tkinter import * <URL:https://docs.python.org/3/library/tkinter.html#tkinter-modules> This is one of many cases where conventions have resolved after some significant code (and documentation) violating the convention entered the standard library. So, it is an uncomfortable fact that Python's Tkinter recommends un-Pythonic idioms — and that will likely remain the case. I applaud attempts to carve out an ever-increasing space where the more Pythonic idiom ‘import tkinter as tk’ is enforced. Be aware, though, that there is a lot of existing code – most of which shouldn't be changed only to fix this – which violates that idiom. -- \ “If we don't believe in freedom of expression for people we | `\ despise, we don't believe in it at all.” —Noam Chomsky, | _o__) 1992-11-25 | Ben Finney _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor