[Tutor] Error Handling in python
Wolfgang Maier
wolfgang.maier at biologie.uni-freiburg.de
Thu Jul 24 14:14:19 CEST 2014
On 24.07.2014 14:09, Chris “Kwpolska” Warrick wrote:
> On Thu, Jul 24, 2014 at 2:01 PM, Wolfgang Maier
> <wolfgang.maier at biologie.uni-freiburg.de> 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 this is not needed, all you need is:
>
> python test.py && python second.py
I agree, that's far more elegant in this case.
>
> However, you need to explicitly stack all the commands you want to
> execute this way — so, if there are more things, `set -e` might also
> be of use. (you would need an even uglier tree for `if`s.)
>
More information about the Tutor
mailing list