execfile return values
Mel Wilson
mwilson at the-wire.com
Fri Oct 3 16:14:58 EDT 2003
In article <mailman.1065195127.15150.python-list at python.org>,
"Enrique" <enrique.palomo at xgs-spain.com> wrote:
>My english is not very good. So, i can't explain like in my native =
>language.
>Cause of that, maybe I have found your mail not very friendly.
>I've read the docs of execfile, of course. And "reread" it before write
>you.
>I only want to know if there is a way to catch the value of and =
>execution
>like in os.system.
>using execfile.
As the docs say, None is what execfile returns. My guess
is that if anything goes wrong in executing the script file,
then an exception will be raised, so (untested code):
try:
execfile('scr.py')
except Exception, details:
print 'execfile failed:', details
In specific cases you can be more precise with the
exception(s) you trap, and the action(s) you take, of course.
Good Luck. Mel.
More information about the Python-list
mailing list