[Baypiggies] Discussion for newbies/beginner night talks
Shannon -jj Behrens
jjinux at gmail.com
Wed Feb 14 00:15:52 CET 2007
#) Using try/except for flow control:
"""Try to actually log the user in.
BASIC IDEA: A million things can go wrong, and there are several ways to
succeed. You want to check for the ways that can succeed and continue on as
soon as one of them does. You want the non-local flow of control that
exceptions provide, but you need it for both success *and* failure.
"""Try to actually log the user in."""
class PasswordAccepted(Exception): pass
if check_password(): # This may raise KeyError.
if check_other_password(): # This may raise KeyError.
self.setError("Invalid username or password.")
More information about the Baypiggies