[Tutor] functions in other files, executing
Thomi Richards
thomi@thomi.imail.net.nz
Thu, 17 Oct 2002 23:24:08 +1300
yes, i am aware of the import function. the problem i am trying to get
around however, is that i have about 20-50 to import, an each one is in
a different directory. i know where the directories are, but i do not
want to fill up sys.path with a whole heap of directories...
then again, maybe this is OK?
On Thu, 17 Oct 2002 10:54:44 +0100 Thus said alan.gauld@bt.com:
> > 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
>
> _______________________________________________
> Tutor maillist - Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
--
"Avoid the Gates of Hell. Use Linux"
Thomi Richards,
thomi@imail.net.nz