Hugh Macdonald wrote: > I'm writing a tool at the moment that reads in an external file (which > can use any Python syntax) > > At the moment, I'm reading the file in using: > > scriptLines = open(baseRippleScript).read() > exec scriptLines > > However, if I raise an exception in my main code, in a function that is > called from the external script, the stack trace just has: > > File "<string>", line 8, in ? > > Ideally, I'd want to be able to avoid throwing exceptions and would > like to, from my main code, print out an error that included the script > name (easily accessible) and the line number (less easily accessible).
exec compile(scriptLines, baseRippleScript, "exec") (but in this case, you might as well use the "execfile" built-in) </F> -- http://mail.python.org/mailman/listinfo/python-list