[Python-ideas] Allow accessing return value inside finally clause

Jasper St. Pierre jstpierre at mecheye.net
Wed Dec 26 04:25:22 CET 2012


Raum, please make sure you reply on-list. I cannot see your replies here.


On Tue, Dec 25, 2012 at 10:09 PM, alex23 <wuwei23 at gmail.com> wrote:

> On 26 Dec, 10:44, Ram Rachum <r... at rachum.com> wrote:
> > I don't think that this makes Python less clear;
>
> How can you possibly say this?
>
> You've changed the `finally` clause from _guaranteed_ execution to
> something utterly inconsistent. In fact, finally blocks would need to
> have _more_ code to guard against all of the different execution
> models you're proposing here. I'm not sure why you think forcing me to
> write more & less obvious code in a finally block is a better trade
> off than you making clear, explicit use of decorators.
>
> Ambiguity does not equate to clarity. Less typing doesn't either.
> Creating small re-usable pieces of code that do the "hard work" for
> you, however, _is a lot more clear_.
>
> > I think it's just another
> > minor feature that might be useful for some people, and for people who
> > don't, it won't matter. How many people use the `for..else` feature, for
> > example? Very, very few people do. I've used it only several times. But
> > it's still part of Python because it helps in a few rare cases, so that
> > makes it worth it *despite* the fact that it might confuse a newbie.
>
> The behaviour of `for..else` doesn't change based on arbitrary
> conditions, whereas what you propose is that the finally blocks
> behaviour is _fundamentally_ different depending on whether the try
> block is fully executed or not, whether an exception is raised or not.
> This is absolutely not the same thing, and trying to pass this concern
> off as "confusing to newbies" is rather disingenuous. The behaviour
> would be _confusing to everybody_.
>
> This is not a valid cost to save you from having to type a few more
> keystrokes to decorate the return value.
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>



-- 
  Jasper
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20121225/e9f6297b/attachment.html>


More information about the Python-ideas mailing list