A RetroSearch Logo

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

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2005-June/054067.html below:

[Python-Dev] PEP 343 rewrite complete

[Python-Dev] PEP 343 rewrite complete [Python-Dev] PEP 343 rewrite completeGuido van Rossum gvanrossum at gmail.com
Thu Jun 2 18:20:14 CEST 2005
On 6/2/05, Phillip J. Eby <pje at telecommunity.com> wrote:
> At 01:08 AM 6/3/2005 +1000, Nick Coghlan wrote:
> >Also, I'm wondering if it would be useful to have a 'closing' template
> >that looked like:
> >
> >    @with_template
> >    def closing(obj):
> >        try:
> >            yield obj
> >        finally:
> >            obj.close()
> 
> +1 if you make it 'if hasattr(obj,"close"): obj.close()' in the finally
> clause, so that it will still work if the type of the object changes.

But then you'd get back the bug where it would silently do nothing
when you pass it the wrong thing; wasn't that argument used against an
earlier proposal to skip calling __exit__() when it doesn't exist?

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
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