J
John [H2O]
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,b):
import numpy
import datetime
return c
def Foo2(a,b):
import datetime
c = Foo1(a,b)
return c
etc...
Above obviously just for the form, but the point is, in some cases I may
import modules twice, but other times I may not use them at all, so should I
import everything into the main module? Or individually import them into
functions. Is there a performance penalty either way?
Pointers to a good reference are appreciated...
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,b):
import numpy
import datetime
return c
def Foo2(a,b):
import datetime
c = Foo1(a,b)
return c
etc...
Above obviously just for the form, but the point is, in some cases I may
import modules twice, but other times I may not use them at all, so should I
import everything into the main module? Or individually import them into
functions. Is there a performance penalty either way?
Pointers to a good reference are appreciated...