Wrox Programmer Forums
BOOK: Beginning Python: Using Python 2.6 and Python 3.1
This is the forum to discuss the Wrox book Beginning Python: Using Python 2.6 and Python 3.1 by James Payne; ISBN: 978-0-470-41463-7
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Python: Using Python 2.6 and Python 3.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old March 24th, 2013, 01:09 PM
Authorized User
Join Date: Jun 2010
Posts: 18
Thanks: 0
Thanked 6 Times in 3 Posts
Default Using Exceptions for Flow Control?

From a software engineering perspective, using exceptions for flow control is considered a bad practice; exceptions should be used for ... exceptions (exceptional/unexpected behavior, failed preconditions), yet many examples in this book do it. Is this something that Python programmers do often or is the author doing this to illustrate the existence of exceptions? It seems like if the intent is to teach people about a topic, it should be taught in a way that mirrors how it ought to be used (and NOT how it ought NOT be used).

For example, one could argue that there exists a precondition for accessing an element of a dictionary that has_key(key) method should return True. Why not then call that method instead of blindly using the key and catching the exception?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Work Flow - Which Control Powerplanner ASP.NET 4 General Discussion 0 May 24th, 2012 08:21 AM
Which Control To Use - Work Flow Powerplanner BOOK: Beginning ASP.NET 4 : in C# and VB 1 May 24th, 2012 08:14 AM
control flow aranjan ASP.NET 1.0 and 1.1 Professional 0 March 29th, 2007 12:44 PM
When to use Exceptions kcraft Pro PHP 1 January 15th, 2005 02:37 PM
Flow Control shmacgregor VS.NET 2002/2003 6 February 25th, 2004 01:05 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.