kevin parks wrote:
> so let's say i have a script called foo.py.
> foo.py uses some things from the random module and therefore has
> 
> import random
> import kp
> import sys
> import time
> 
> etc. & co.  in it
> 
> but foo.py also imports a module kp which also
> happens to import random.
> 
> Should i only be importing random once or are you saying it
> is just fine to import a module that imports another module that
> you actually have already imported.

It's fine. Each module that needs to use random (for example) should 
import it. Only the first import to be executed has any appreciable 
cost; the subsequent ones just put a reference to the already-loaded and 
cached module into the current module namespace.

Kent

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to