[Python-3000] self-contained exceptions

Collin Winter collinw at gmail.com
Wed Jan 10 19:05:48 CET 2007


On 1/10/07, Jim Jewett <jimjjewett at gmail.com> wrote:
> On 1/10/07, Collin Winter <collinw at gmail.com> wrote:
> > re = get_resource()
> ...
> > except RareException as re:
> ...
> > re.use_resource()
>> > So 're = None; del re;' is *only* executed if the except body is executed.
>> So re.use_resource() will usually work (as it does today).
>> The difference is that when it doesn't work, you'll see something
> about NoneType instead the exception type.

You're forgetting about the 'del N'; re.use_resource() will fail with
a NameError at the call site.
Collin Winter


More information about the Python-3000 mailing list

AltStyle によって変換されたページ (->オリジナル) /