[Tutor] running a script from IDLE

Scott Widney SWidney@ci.las-vegas.nv.us
Mon, 11 Mar 2002 17:47:59 -0800


> >Hmmm... in Alan's example above, you could always have the
> >function return a boolean indicating its success or failure
> >at performing the task. One level up you'd have logic that
> >would react accordingly. Now it's back to being functional
> >again....
> 
> Well, I don't necessarily want to bypass all the try/except
> syntax by trying to handle errors using return values.

OK, I can see that. So would this type of setup work:

try:
  object.method()     # Exception "raised" in method.
except derivedError:  # Derived errors being errors created
  blah_blah()         # for this particular object.

(i.e. wrap the method call in a try, as opposed to having the try/except
coded in the method)? I'm unsure if that's possible -- I don't know if
nested scopes changed this behavior or not. I'm thinking of the old LGB
acronym; in older versions of Python if things didn't happen in the Local
vicinity, Python hopped right up to Global without any regard to intervening
levels.

Scott