On Fri, 23 Jan 2009 17:48:19 +0100, Diez B. Roggisch wrote:
> The only valid reason for doing imports inside functions is if you
> otherwise get into circular dependency hell, or have modules that need
> some manipulation of the sys.path before they actually can be imported.
Or if you want to mak
On Fri, 23 Jan 2009 22:49:34 +0100, Christian Heimes wrote:
Jean-Paul Calderone schrieb:
BTW, if you ever find you are starting to write multi-threaded
applications
then you'll really regret it if you reuse code which does imports from
inside functions. If two or more threads try to import a mo
Jean-Paul Calderone schrieb:
>> BTW, if you ever find you are starting to write multi-threaded
>> applications
>> then you'll really regret it if you reuse code which does imports from
>> inside functions. If two or more threads try to import a module
>> simultaneously then one of them might find i
On 23 Jan 2009 18:50:00 GMT, Duncan Booth wrote:
[snip]
BTW, if you ever find you are starting to write multi-threaded applications
then you'll really regret it if you reuse code which does imports from
inside functions. If two or more threads try to import a module
simultaneously then one of t
"John [H2O]" wrote:
> So it isn't inefficient to import a bunch of modules that may not be
> used, say if only one function is used that doesn't rely on a larger
> module like numpy or pylab?
>
Not really. If you import it at all then you might as well import it on
startup i.e. at the top of th
Steve Holden schrieb:
Diez B. Roggisch wrote:
[...]
The only valid reason for doing imports inside functions is if you
otherwise get into circular dependency hell, or have modules that need
some manipulation of the sys.path before they actually can be imported.
This is never true for system modu
Diez B. Roggisch wrote:
[...]
> The only valid reason for doing imports inside functions is if you
> otherwise get into circular dependency hell, or have modules that need
> some manipulation of the sys.path before they actually can be imported.
> This is never true for system modules, and certainl
John [H2O] schrieb:
So it isn't inefficient to import a bunch of modules that may not be used,
say if only one function is used that doesn't rely on a larger module like
numpy or pylab?
Well, importing can take bit of time - but that's a short latency at
startup-time, if anything.
And if you
y been imported before.
>
>
> The only valid reason for doing imports inside functions is if you
> otherwise get into circular dependency hell, or have modules that need
> some manipulation of the sys.path before they actually can be imported.
> This is never true for system modules
John [H2O] schrieb:
Hello, Im writing some modules and I am a little confused about where to
place my imports...
I don't really do any class programming yet, just defining a bunch of
functions, so presently I have something along the lines of:
import sys
import os
import traceback
def Foo1(a,
e? Or individually import them into
functions. Is there a performance penalty either way?
Pointers to a good reference are appreciated...
--
View this message in context:
http://www.nabble.com/Where-to-place-imports-tp21627895p21627895.html
Sent from the Python - python-list mailing list archi
11 matches
Mail list logo