Calling user defined functions from a different script..

Aaron Brady castironpi at
Wed Apr 15 14:51:29 CEST 2009

On Apr 15, 6:33 am, "venutaurus... at"
<venutaurus... at> wrote:
> Hello all,
>           I have a situation where I need to call functions present in
> a different script whose hierarchy is something like below:
> C:\Pythonlib\uitl\ {Place where my functions definitions are
> present}
> C:\Scripts\ { Place where function calls are made}
>            In such a situation how can I import functions from
> and use it in
> Please let me know if you need any further details.
> Thank you,
> Venu Madhav.

>From what I understand, you just want a certain line in a certain
file.  The line is the path to the directory you want to import from,
pythonlib\util.  The file is {python_direcotry\}Lib\site-packages

Here's mine:

C:\Programs\Python25\Lib\site-packages>type locals.pth
/Documents and Settings/usr/My Documents/
/Documents and Settings/usr/Desktop/working/imptest/

If you want to import multiple directories, you need another file
which will be blank.  The blank file goes in the directory you will be
importing.  It is called ''.


 Directory of C:\Documents and Settings\usr\My Documents\Lib

04/08/2008  03:35 PM                 0

Then I can do:

Python 2.5.4 (r254:67916, Dec 23 2008
Type "help", "copyright", "credits" o
>>> import Lib

I'm not sure about other versions than 2.5.

More information about the Python-list mailing list