can try expect have if else.
Ganesh Pal
ganesh1pal at gmail.com
Sun Feb 21 12:39:30 EST 2016
On Sun, Feb 21, 2016 at 10:37 PM, Ben Finney <ben+python at benfinney.id.au> wrote:
> What result do you get when running that code? What empirical reason do
> you have to think it would work or not work?
I wanted to know was is it good to have if else with in a try expect
block , I was checking more from the programming perspective and if
I need to avoid it and if its recommended
>> 2. How can the above code be improved
>
> The following sequence of statements::
>
> raise Exception("/nfs_mount is not mounted. Dataset create failed !!!")
> return False
>
> do not make sense. The ‘return‛ statement will never be reached. So your
> intent must be something other than what is expressed by that code.
>
I was using it with create_data function in the below code . If
create_dataset failed the exception would be caught , I think you are
right I need not worry about returning False
functions = [create_logdir, create_dataset]
for func in functions:
try:
func()
except Exception as e:
logging.error(e)
return False
Regards,
Ganesh
More information about the Python-list
mailing list