[FRPythoneers] Question about Try/Except
brunson at level3.net
Mon Jun 3 15:13:35 MDT 2002
Listen to the wise man...
If you *ever* use a bare exception, always re-raise the same exception
you caught unless you are very sure of everything that could have gone
* Sean Reifschneider (jafo at tummy.com) [020603 15:09]:
> On Mon, Jun 03, 2002 at 03:16:04PM -0600, J. Wayde Allen wrote:
> > try:
> > surname = form["last_name"].value
> > except:
> > Display("You must supply a first and last name. Please go back.")
> > raise SystemExit
> Using "bare exception" is considered bad form because it masks other
> errors. You probably wanted to do:
> surname = form.get('last_name'):
> if not surname or not string.strip(surname):
> dictionary.get('key') doesn't raise an exception if that key doesn't exist,
> it returns "None". "if not string" fails if the string is None *OR* if
> it's an empty string.
> In this case, I don't know why you are getting an empty string when you
> moved it to another machine. You should probably be checking for the empty
> string anyway, and possibly only white-spaces, but in the end you can't
> prevent somone from not putting in a last name...
> The blood of the guitar was Chuck Berry Red.
> -- Meatloaf
> Sean Reifschneider, Inimitably Superfluous <jafo at tummy.com>
> tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python
> This message sent by the FRPythoneers mailing list.
> Unsubscribe: echo unsubscribe | FRPythoneers-request at lists.community.tummy.com
> URL: http://lists.community.tummy.com/mailman/listinfo/frpythoneers
Eric Brunson brunson at level3 dot net
tcA thgirypoC muinelliM latigiD eht detaloiv tsuj evah uoY
More information about the FRPythoneers