execute script in certain directory

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Tue Jul 10 01:45:35 CEST 2007


En Mon, 09 Jul 2007 14:09:40 -0300, Alex Popescu  
<the.mindstorm.mailinglist at gmail.com> escribió:

> Interesting. I was wondering about the opposit: being in the parent
> dir, how can I run a module from a package. (the current behavior when
> running python dir_name\module.py is to consider the dir_name the
> current dir and this breaks all imports). I am pretty sure this is
> answered somewhere, but I must confess that so far I haven't been able
> to find it :-(.

python dir_name\module.py does NOT change the current dir. It prepends  
dir_name to sys.path, if this is what you mean.
The short answer is: don't place standalone scripts inside a package; see  
this thread:
http://groups.google.com/group/comp.lang.python/browse_thread/thread/c44c769a72ca69fa/

-- 
Gabriel Genellina




More information about the Python-list mailing list