I think the bottom line on this is using your own sense of risk/reward with
each given module imported. Some modules (Tkinter comes to mind) it makes
sense to pollute while others it doesn't.
Harlin
Peter Hansen [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Peter Mayne wrote:
Peter Hansen wrote:
In general, unless the names being imported are *guaranteed*
never to be rebound, it is a very bad idea to use import *,
and it's still a bad idea in almost all cases anyway, for
reasons already given by others.
Since I've been playing with PyQt lately...
Is qt not one of the
Peter Mayne wrote:
Peter Hansen wrote:
and it's still a bad idea in almost all cases anyway
Since I've been playing with PyQt lately...
Is qt not one of the almost all cases? From the limited number of
examples I've seen, it seems to be common to do
from qt import *
This sort of thing seems
Is there really a major performance difference between doing the
following:
import Tkinter as TK
TK.Label(yada yada)
OR
from Tkinter import *
Label(yada yada)
I'm unable to tell a real difference other than in the code writing
:-).
Thanks,
Harlin
--
Is there really a major performance difference between doing the
No.
I'm unable to tell a real difference other than in the code writing
:-).
The difference is that the from-syntax may cause name space pollution. See
the FAQ:
http://www.python.org/doc/faq/programming.html#id12
--
Regards,
Diez B. Roggisch wrote:
[Harlin Seritt]:
Is there really a major performance difference between doing the
No.
Actually, if you are using a name in another module repeatedly
in an inner loop, it can make a big difference if you have to lookup
the name in the module repeatedly. In that case, just
Michael Hoffman wrote:
But don't do from Tkinter import * for the reasons Diez has
identified in the FAQ.
It is so annoying to read some code and having to guess from where the
do_complicated_stuff() function is imported from.
Explicit importing is by far the moste preferable.
--
hilsen/regards
Actually, if you are using a name in another module repeatedly
in an inner loop, it can make a big difference if you have to lookup
the name in the module repeatedly. In that case, just explicitly
import the name you want to use repeatedly:
Ok - but if that really hits the wall for some part
Diez B. Roggisch wrote:
I'm unable to tell a real difference other than in the code writing
:-).
The difference is that the from-syntax may cause name space pollution. See
the FAQ:
http://www.python.org/doc/faq/programming.html#id12
Ultimately more important than mere pollution are the
latent
Peter Hansen [EMAIL PROTECTED] writes:
Ultimately more important than mere pollution are the
latent problems this can cause if any of the names in
the original module can ever be re-bound.
You know, this is another reason the compiler really ought to (at
least optionally) check for such
Paul Rubin http wrote:
Peter Hansen [EMAIL PROTECTED] writes:
Ultimately more important than mere pollution are the
latent problems this can cause if any of the names in
the original module can ever be re-bound.
You know, this is another reason the compiler really ought to (at
least
11 matches
Mail list logo