simplest way to visit 3 subdirectories with a command?
Tim Chase
python.list at tim.thechases.com
Tue Aug 18 13:11:54 EDT 2009
> could you inform how to compose a py-file (for soft installation),
> that will visit 3 subdirectories (eg subdir1, subdir2, subdir3) and
> invoke a command "python setup.py install" in each subdirectory?
> I know there should be a simple solution available in Python
If you're executing "python setup.py install", that sounds like
you're operating at the shell level, not within python. In which
case, I'd just use my shell's iteration capabilities:
# running bash on a *nix-like OS
bash$ for dir in subdir1 subdir2 subdir3; do pushd $dir;
python setup.py install; popd; done
# running within Win32's cmd.exe
c:\temp\> for %f in (subdir1 subdir2 subdir3) do pushd %f &
python setup.py install & popd
or something of the sort. Remember in Win32 that the variables
have to be escaped if you put them in a batch file ("%%f" instead
of "%f")
-tkc
More information about the Python-list
mailing list