- The most severe problem is that this treats commas in {scripts} as if they were top-level commas.
- The consensus has changed from tabs to spaces, both for the output of the script as well as the indentation of the script itself. Actually, even if the consensus had not changed, tabs should NEVER be used for alignment, only for indentation.
- The destination file should not be required to exist.
- Check whether the required arguments exist before doing anything else.
- There should be a check for whether open(fname, "mode") succeeded, rather than just if the file exists.
- Avoid the repeated calls to .strip()
- General review by somebody who actually knows python. More comments would be helpful for those of us who don't (what's with all the [-1]).
Is it worth saving this or should it be rewritten from scratch?