[Tutor] Defining & Importing Functions

James.Rocks@equant.com James.Rocks@equant.com
Thu, 17 Oct 2002 13:26:38 +0100


Hi,

Up until recently I kept my programs in the Python (c:\python21) install
directory (which somebody told me was not a good idea) ... that in mind I
created a sub-folder for them and put them in there but that caused
problems in that I didn't seem to be able to import from a specified
location i.e. all files imported appeared to need to be in the main python
directory which is (to my mind at any rate) a severe limitation. However,
knowing me, it's probably me & not python :-)

I also have problem running functions that are in the same text file as my
main program ... e.g. if I define a function called "SMPTAlert()" in my
main program how do I "call" it?

My preferred way of organising my files would be to have a main program
file (with all the main routines directly associated with that part of the
program) in one file & any common project functions in a separate project
function file ... these would all be in the project directory. Any routines
that are reusable beyond the scope of the project would go in a separate
project file in a comon folder reachable by any project programs ... in
this case (and I'm unsure whether this is wise or not) that will be the
Python install folder.

Any thoughts?

James

James C. Rocks
Equant
Archway House
Canary Wharf
London E14 9SZ.