Re: [Tutor] Error Handling in python

2014-07-25 Thread jitendra gupta
@All Thanks a lot, Yes "set -e" It work fine. This is what I am looking for but I got some extra things to learn :) . Thanks you again Thanks Jitendra On Thu, Jul 24, 2014 at 6:10 PM, Wolfgang Maier < wolfgang.ma...@biologie.uni-freiburg.de> wrote: > On 24.07.2014 14:37, Chris “Kwpolska” Warr

Re: [Tutor] Error Handling in python

2014-07-24 Thread Wolfgang Maier
On 24.07.2014 14:37, Chris “Kwpolska” Warrick wrote: It’s recommended to switch to the [[ syntax anyways, some people consider [ deprecated. Also, [ is actually /bin/[ while [[ lives in your shell (and is therefore faster). About the equals sign, == is the preferred syntax, and = is also consi

Re: [Tutor] Error Handling in python

2014-07-24 Thread Chris “Kwpolska” Warrick
On Thu, Jul 24, 2014 at 2:23 PM, Wolfgang Maier wrote: > On 24.07.2014 14:19, Chris “Kwpolska” Warrick wrote: >> >> > python test.py > if [ $? = 0 ]; then > python second.py > fi > > as your shell script. The [ ] and = should be doubled. >>> >>> >>

Re: [Tutor] Error Handling in python

2014-07-24 Thread Wolfgang Maier
On 24.07.2014 14:19, Chris “Kwpolska” Warrick wrote: python test.py if [ $? = 0 ]; then python second.py fi as your shell script. The [ ] and = should be doubled. ?? why that ? Double brackets can do more: http://stackoverflow.com/questions/2188199/how-to-use-double-or-single-br

Re: [Tutor] Error Handling in python

2014-07-24 Thread Chris “Kwpolska” Warrick
On Thu, Jul 24, 2014 at 2:14 PM, Wolfgang Maier wrote: > On 24.07.2014 14:09, Chris “Kwpolska” Warrick wrote: >> >> On Thu, Jul 24, 2014 at 2:01 PM, Wolfgang Maier >> wrote: >>> >>> Try something like this (assuming bash): >>> >>> python test.py >>> if [ $? = 0 ]; then >>> python second.py >

Re: [Tutor] Error Handling in python

2014-07-24 Thread Wolfgang Maier
On 24.07.2014 14:09, Chris “Kwpolska” Warrick wrote: On Thu, Jul 24, 2014 at 2:01 PM, Wolfgang Maier wrote: Try something like this (assuming bash): python test.py if [ $? = 0 ]; then python second.py fi as your shell script. The [ ] and = should be doubled. ?? why that ? But all th

Re: [Tutor] Error Handling in python

2014-07-24 Thread Chris “Kwpolska” Warrick
On Thu, Jul 24, 2014 at 2:01 PM, Wolfgang Maier wrote: > Try something like this (assuming bash): > > python test.py > if [ $? = 0 ]; then > python second.py > fi > > as your shell script. The [ ] and = should be doubled. But all this is not needed, all you need is: python test.py && python

Re: [Tutor] Error Handling in python

2014-07-24 Thread Steven D'Aprano
On Thu, Jul 24, 2014 at 05:05:24PM +0530, jitendra gupta wrote: > Hi All > > My shell script is not throwing any error when I am having some error in > Python code. This is a question about the shell, not about Python. I'm not an expert on shell scripting, but I'll try to give an answer. > ~~

Re: [Tutor] Error Handling in python

2014-07-24 Thread Wolfgang Maier
On 24.07.2014 13:35, jitendra gupta wrote: Hi All My shell script is not throwing any error when I am having some error in Python code. test.py ~~ def main(): print "Test" #some case error need to be thrown raise Exception("Here is error") if __name__ == "__main__"

Re: [Tutor] Error Handling in python

2014-07-24 Thread Chris “Kwpolska” Warrick
On Thu, Jul 24, 2014 at 1:35 PM, jitendra gupta wrote: > Hi All > > My shell script is not throwing any error when I am having some error in > Python code. > > In this case, I dont want to run my second.py > Even I am throwing error from my test.py, but still second.py is getting > executed, whic

[Tutor] Error Handling in python

2014-07-24 Thread jitendra gupta
Hi All My shell script is not throwing any error when I am having some error in Python code. test.py ~~ def main(): print "Test" #some case error need to be thrown raise Exception("Here is error") if __name__ == "__main__" main() ~~ second.py ~~ def