Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #103316 > unrolled thread

Re: can try expect have if else.

Started byIan Kelly <ian.g.kelly@gmail.com>
First post2016-02-21 12:22 -0700
Last post2016-02-21 12:22 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: can try expect have if else. Ian Kelly <ian.g.kelly@gmail.com> - 2016-02-21 12:22 -0700

#103316 — Re: can try expect have if else.

FromIan Kelly <ian.g.kelly@gmail.com>
Date2016-02-21 12:22 -0700
SubjectRe: can try expect have if else.
Message-ID<mailman.23.1456082530.20994.python-list@python.org>
On Feb 21, 2016 9:13 AM, "Ganesh Pal" <ganesh1pal@gmail.com> wrote:
>
> Hi Team,
>
> Iam on python 2.6 , need input on the below piece of code.

Python 2.6 isn't supported and hasn't been since October 2013. Is there
something preventing you from upgrading to 2.7?

> EXIT_STATUS_ERROR=1
>
> def create_dataset():
>     """
>      """

Empty docstring is pointless.

>     logging.info("Dataset create.....Started !!!")

This is just a pet peeve of mine, but do info-level log messages really
need triple exclamation marks?

>     try:
>         if os.path.ismount("/nfs_mount"):
>             touch_file("inode_fixcrc.txt")

Is this file really meant to be created in the current working directory,
or is it supposed to be inside the /nfs_mount?

>             logging.info("Dataset create.....Done !!!")
>         else:
>             raise Exception("/nfs_mount is not mounted. Dataset create
> failed !!!")
>             return False
>     except Exception as e:
>             logging.error(e)
>             sys.stderr.write("Dataset create failed...Exiting !!!")
>             sys.exit(EXIT_STATUS_ERROR)
>     return True
>
> 1. Can we have if else with in a try except block

Yes, of course.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web