I have tried the following two snippets which both results in the same error
import os, glob os.chdir('users/spyros/desktop/3NY8MODELSHUMAN/') homology_models = glob.glob('*.pdb') for i in range(len(homology_models)): python serialize_PIPELINE_models.py homology_models[i] import os, sys path = "/users/spyros/desktop/3NY8MODELSHUMAN/ dirs = os.listdir(path) for file in dirs: python serialize_PIPELINE_models.py The error, respectively for each snipped, read: File "<stdin>", line 2 python serialize_PIPELINE_models.py homology_models[i] ^ SyntaxError: invalid syntax File "<stdin>", line 2 python serialize_PIPELINE_models.py ^ SyntaxError: invalid syntax In the first snippet, the final line reads: 'python' (calling the interpreter) 'serialize_PIPELINE_models.py' (calling my python program) 'homology_models[i]' (the file to run it on) the glob.glob routine returns a list of files, so maybe python does not allow the syntax "python (call interpreter)" "list entry" ? Many thanks. Spyros On Fri, May 18, 2012 at 7:57 PM, Alan Gauld <alan.ga...@btinternet.com>wrote: > On 18/05/12 19:23, Spyros Charonis wrote: > >> Dear Python community, >> >> I have a set of ~500 files which I would like to run a script on. >> > > ...Is there a way in which I can iteratively execute my script > > over all 500 files > > Yes. > You could use os.walk() or the glob module depending on whether > the files are in a folder heirarchy or a single folder. > > That will give you access to each file. > Put your functionality into a function taking a single file > as input and a list to which you append the new data. > Call that function for each file in turn. > > Try that and if you get stuck come back with a more specific question, the > code you used and the full error text. > > -- > Alan G > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > > > ______________________________**_________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/**mailman/listinfo/tutor<http://mail.python.org/mailman/listinfo/tutor> >
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor