[Tutor] functions in other files, executing

alan.gauld@bt.com alan.gauld@bt.com
Thu, 17 Oct 2002 10:54:44 +0100


> I am assuming that there is an easier way to execute a function from
> another file, assuming that you know it's location, and the function
> name than importing the file as a module?? 

There might be another way(although I can't think of it!) 
but the easiest way is to import the module or import 
the function name:

import mod
mod.foo()   # more typing but safest

OR

from mod import foo   # usually a bad idea...
foo()

Alan g.
Author of the 'Learning to Program' web site
http://www.freenetpages.co.uk/hp/alan.gauld