Re: usage of try except for review.

2016-03-01 Thread Steven D'Aprano
On Mon, 29 Feb 2016 07:13 pm, Ganesh Pal wrote: > def run_cmd_and_verify(cmd, timeout=1000): > try: > out, err, ret = run(cmd, timeout=timeout) > assert ret ==0,"ERROR (ret %d): " \ > " \nout: %s\nerr: %s\n" % (ret, out, err) Do not use assert for error checki

Re: usage of try except for review.

2016-03-01 Thread Steven D'Aprano
On Tue, 1 Mar 2016 04:38 am, Chris Angelico wrote: > On Tue, Mar 1, 2016 at 4:34 AM, Ganesh Pal wrote: >> On Mon, Feb 29, 2016 at 10:10 PM, Dennis Lee Bieber >> wrote: >> >>> Ask yourself: Will my program still work if I remove all the >>> assert >>> statements. If the answer is

Re: usage of try except for review.

2016-02-29 Thread Ganesh Pal
> I have tried down the code to Read "I have tried down the code to " as I have trimmed down the code as below Ganesh -- https://mail.python.org/mailman/listinfo/python-list

Re: usage of try except for review.

2016-02-29 Thread Ganesh Pal
> No, Dennis was correct. You should assume that "assert" can > potentially be replaced with "pass" and your program will continue to > work. Thanks Chris for clarifying Dennis point of view , >>try: >>if not run_cmd_and_verify(cmd, timeout=3600): > > Since your vers

Re: usage of try except for review.

2016-02-29 Thread Chris Angelico
On Tue, Mar 1, 2016 at 4:34 AM, Ganesh Pal wrote: > On Mon, Feb 29, 2016 at 10:10 PM, Dennis Lee Bieber > wrote: > >> Ask yourself: Will my program still work if I remove all the assert >> statements. If the answer is "No", then you should not be using an assert. > > You meant if the answ

Re: usage of try except for review.

2016-02-29 Thread Ganesh Pal
On Mon, Feb 29, 2016 at 10:10 PM, Dennis Lee Bieber wrote: > Ask yourself: Will my program still work if I remove all the assert > statements. If the answer is "No", then you should not be using an assert. You meant if the answer is "NO" then I should be using asset ? > Can your

Re: usage of try except for review.

2016-02-29 Thread Ganesh Pal
Iam really sorry , I will have to resend my question again , because the earlier post had mistakes and formatting was bad , so apologies for top posting will try to avoid such mistakes in future. Iam on python 2.6 and Linux , need your suggestion on the usage of try and except in this program #

usage of try except for review.

2016-02-29 Thread Ganesh Pal
Iam on python 2.6 and Linux , need your suggestion on the usage of try and except in this program and Modified code: #!/usr/bin/env python """ """ import os import shlex import subprocess import sys import time import logging import run import pdb def run_cmd_and_verify(cmd, timeo