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/2003-April/034586.html below:

[Python-Dev] Garbage collecting closures

[Python-Dev] Garbage collecting closures [Python-Dev] Garbage collecting closuresGuido van Rossum guido@python.org
Mon, 14 Apr 2003 12:08:04 -0400
> On Mon, 2003-04-14 at 11:52, Phillip J. Eby wrote:
> > If I understand correctly, it should also be breakable by deleting 'foo' 
> > from the outer function when you're done with it.  E.g.:
> > 
> > def bar(a):
> >       def foo():
> >           return None
> >           x = a
> >           foo()
> > 
> >       del foo   # clears the cell and breaks the cycle

> From: Jeremy Hylton <jeremy@zope.com>
> 
> You haven't tried this, have you? ;-)
> 
> SyntaxError: can not delete variable 'foo' referenced in nested scope
> 
> Since foo() could escape bar, i.e. become reachable outside of bar(), we
> don't allow you to unbind foo.

I don't see the reason for this semantic restriction.  IMO it could
just as well be a runtime error (e.g. raising UnboundLocalError).

--Guido van Rossum (home page: http://www.python.org/~guido/)



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