[Python-Dev] Python FAQ: Why doesn't Python have a "with" statement?
Nick Coghlan
ncoghlan at gmail.com
Sun Jun 15 07:20:32 CEST 2008
Greg Ewing wrote:
> Cesare Di Mauro wrote:
>
>> The same happens with:
>>
>> from Tkinter import *
>>
>> which is a fair common instruction...
>
> ...and which should *not* be used in most cases, for
> the same reason.
>
> All those tutorials that start out with 'from something
> import *' are doing a lot of harm to the impressionable
> minds of new programmers, IMO.
>
Yeah, the only remotely legitimate usage of it that I am aware of is for
modules with a hybrid implementation where the public Python module does
a "from _native_module import *" to get the rest of the implementation.
And even that is somewhat arguable.
To go back to Cesare's most recent example:
t = ScrolledText.ScrolledText(master, width=60, height=37)
t.insert(Tkinter.END, self.log.getText())
t.configure(state=Tkinter.DISABLED)
t.see(Tkinter.END)
t.pack(fill=Tkinter.BOTH)
can look like:
tk = Tkinter:
st = ScrolledText.ScrolledText(master, width=60, height=37):
st.insert(tk.END, self.log.getText())
st.configure(state=tk.DISABLED)
st.see(tk.END)
st.pack(fill=tk.BOTH)
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
---------------------------------------------------------------
http://www.boredomandlaziness.org
More information about the Python-Dev
mailing list