Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #103316
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: can try expect have if else. |
| Date | 2016-02-21 12:22 -0700 |
| Message-ID | <mailman.23.1456082530.20994.python-list@python.org> (permalink) |
| References | <CACT3xuWMtxjC+6idsj_RfWVXLS-QCzQSdGaj2Kk4g4_EH9_wPA@mail.gmail.com> |
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.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: can try expect have if else. Ian Kelly <ian.g.kelly@gmail.com> - 2016-02-21 12:22 -0700
csiph-web