How can I import a py script by its absolute path name?

Edvard Majakari edvard+news at majakari.net
Thu Jul 14 07:52:31 EDT 2005


could ildg <could.net at gmail.com> writes:

> I want to import c:\xxx\yyy\zzz.py into my programme,
> What should I do?
> Thank you~

import sys
sys.path.append('c:\xxx\yyy')
import zzz

(Untested, similar idiom would work in *nix systems, never programmed in
Windows)

However, I guess it is not very usual you should need to import stuff from
arbitrary locations. Consider publishing those modules in normal Python
include path (just see what ''print sys.path'' produces)

-- 
# Edvard Majakari		Software Engineer
# PGP PUBLIC KEY available    	Soli Deo Gloria!

$_ = '456476617264204d616a616b6172692c20612043687269737469616e20'; print
join('',map{chr hex}(split/(\w{2})/)),uc substr(crypt(60281449,'es'),2,4),"\n";



More information about the Python-list mailing list