A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-May/053459.html below:

[Python-Dev] Pre-PEP: Unifying try-except and try-finally

[Python-Dev] Pre-PEP: Unifying try-except and try-finally [Python-Dev] Pre-PEP: Unifying try-except and try-finallyFredrik Lundh fredrik at pythonware.com
Fri May 6 18:36:57 CEST 2005
François Pinard wrote:

> > >     f = None
> > >     try:
> > >         f = action1(...)
> > >     ...
> > >     finally:
> > >         if f is not None:
> > >             action2(f)

> > f = action1()
> > try:
> >     ...
> > finally:
> >     action2(f)

> > I can't see how this would ever do something different than your version.

> Oh, the problem is that if `action1()' raises an exception (and this is
> why it has to be within the `try', not before), `f' will not receive
> a value, and so, may not be initialised in all cases.  The (frequent)
> stunt is a guard so this never becomes a problem.

in Guido's solution, the "finally" clause won't be called at all if action1 raises
an exception.

</F>



More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4