Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #103315 > unrolled thread
| Started by | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| First post | 2016-02-21 13:49 -0500 |
| Last post | 2016-02-21 13:49 -0500 |
| 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.
Re: can try expect have if else. Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-02-21 13:49 -0500
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Date | 2016-02-21 13:49 -0500 |
| Subject | Re: can try expect have if else. |
| Message-ID | <mailman.22.1456080563.20994.python-list@python.org> |
On Sun, 21 Feb 2016 21:42:18 +0530, Ganesh Pal <ganesh1pal@gmail.com>
declaimed the following:
>Hi Team,
>
>Iam on python 2.6 , need input on the below piece of code.
>
>
>EXIT_STATUS_ERROR=1
>
>def create_dataset():
> """
> """
> logging.info("Dataset create.....Started !!!")
> try:
> if os.path.ismount("/nfs_mount"):
> touch_file("inode_fixcrc.txt")
> logging.info("Dataset create.....Done !!!")
> else:
> raise Exception("/nfs_mount is not mounted. Dataset create
>failed !!!")
> return False
The return will never be reached -- executing "raise" will result in an
immediate transfer to ...
> except Exception as e:
... this exception handler...
> logging.error(e)
> sys.stderr.write("Dataset create failed...Exiting !!!")
> sys.exit(EXIT_STATUS_ERROR)
... which forcibly exits the program.
> return True
As a result, this True is of no real use. If the function doesn't
succeed, the program kills itself; the only way a caller gets control back
is when the function succeeds, so there is no need to test for success.
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
Back to top | Article view | comp.lang.python
csiph-web