I'm converting some old bash scripts to python. There's lots of places where I'm doing things like "rm $source_dir/*.conf". The best way I can see to convert this into python is:
configs = glob.glob(os.path.join(source_dir, '*.conf')) for conf_file in configs: shutil.copy(conf_file, conf_dir) which is pretty clunky. The old bash script ran under cygwin on windows, and the cygwin layer handled the slash-backslash business for me. Is there a better way to do what I'm doing? I don't want to use any of the popen() variants to call a real shell. The problem I'm trying to solve is that fork/exec is painfully slow under cygwin, so that would defeat the whole purpose. The idea interface I see would be one like: shutil.copy([source_dir, '*.conf'], conf_dir) the idea is that if the first argument is a list (or maybe any iterable other than a string?), it would automatically get run through os.path.join(). And, the result would always get passed through glob (), just like a normal shell would. Does anything like this exist? I'm currently using python 2.5.1. It's possible, but moderately painful, to move to a newer version. -- http://mail.python.org/mailman/listinfo/python-list