importing
M.-A. Lemburg
mal at lemburg.com
Thu Oct 14 06:21:44 EDT 1999
Peter Posselt Vestergaard wrote:
>
> Hi
> How do I import a library file which isn't placed in the same directory
> as the python-file and neither in a directory in my path???
> I've made my own library file called pythonlib.py and if I places it in
> the same directory as my program and writes 'import pythonlib' in the
> beginning of my programfile it works fine, but I can't figure out how to
> find it elsewhere.
> Furthermore: How do I access the functions in my library then I've
> included it from somewhere not in the same directory? Will it still be
> enough just to write pythonlib.function()???
> I've tried the solutions in the manual pages, but I can't make it work.
See the docs on the builtin __import__ function for details.
pythonlib = __import__('/my/python/code/pythonlib',globals(),locals())
--
Marc-Andre Lemburg
______________________________________________________________________
Y2000: 78 days left
Business: http://www.lemburg.com/
Python Pages: http://www.lemburg.com/python/
More information about the Python-list
mailing list