0
How do I convert a for loop from bash to python
for example: for f in *; do cd $f git clone <> cd ../ done;
3 ответов
+ 1
I don't have python in front of me (just docs and Google) so conceptually (until someone answers, or this helps you think about the problem):
for f in * .... a list of filesystem iterables. To load an iterable list in python you can use 'dir' or 'os.walk'.
You don't need to 'cd' in python, just iterate/walk.
To shell out and execute 'git', you can use GitPython (https://github.com/gitpython-developers/GitPython) or 'subprocess.POpen'.
0
thank you. Will try that
0
I am totally stuck here.. I am not sure how to change directory and run a command in that directory, exit and move on to the next directory in a loop. can you please help