how to improve simple python shell script (to compile list of files)
Maarten van Reeuwijk
maarten at remove_this_ws.tn.tudelft.nl
Sat Oct 15 07:40:31 EDT 2005
Jari Aalto wrote:
>
> [Keep CC, thank you]
>
> Please suggest comments how can I make this script to work
> from bash. Also how can I skip better the [0] argument from
> command line without hte extra variable i?
Didn't check, but something like this?
#!/bin/python
import os, sys, py_compile;
i = 0;
for arg in sys.argv:
file = os.path.basename(arg);
dir = os.path.dirname(arg);
i += 1;
if i > 1 and os.path.exists(dir):
os.chdir(dir);
print "compiling %s\n" % (file);
py_compile.compile(file);
--
===================================================================
Maarten van Reeuwijk dept. of Multiscale Physics
Phd student Faculty of Applied Sciences
maarten.ws.tn.tudelft.nl Delft University of Technology
More information about the Python-list
mailing list