Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #103310
| From | Ganesh Pal <ganesh1pal@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: can try expect have if else. |
| Date | 2016-02-21 23:09 +0530 |
| Message-ID | <mailman.17.1456076380.20994.python-list@python.org> (permalink) |
| References | <CACT3xuWMtxjC+6idsj_RfWVXLS-QCzQSdGaj2Kk4g4_EH9_wPA@mail.gmail.com> <858u2e0z7q.fsf@benfinney.id.au> |
On Sun, Feb 21, 2016 at 10:37 PM, Ben Finney <ben+python@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
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: can try expect have if else. Ganesh Pal <ganesh1pal@gmail.com> - 2016-02-21 23:09 +0530
csiph-web