kamal
kamal

Reputation: 9785

how can i print return values (success/failure) from a python script

i have a python script, that connects to a web service using suds client, and gets data. Now based on what was queried, i can get a true or false as results. so when i run the script with correct data values, i get nothing on the stdout, but when i use incorrect data, i get "data error", based on :

except Exception, e:
    print 'data error'

Is there a way to get the values of success and failure from a python script, so in case of failure, i can notify the user. I am referring to the return values frm a failed/success python script

Upvotes: 1

Views: 1688

Answers (1)

Cédric Julien
Cédric Julien

Reputation: 80751

What you get on stdout is what you print in your script (so in your case, you will get 'data error' on stdout in case of error).

If you want to handle correctly the return code of you python script, take a look to the sys.exit(return_code) method which will return to the caller the return_code (in general 0 when all is OK, something else when something bad happend)

Upvotes: 3

Related Questions