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/034584.html below:

[Python-Dev] Garbage collecting closures

[Python-Dev] Garbage collecting closures [Python-Dev] Garbage collecting closuresJeremy Hylton jeremy@zope.com
14 Apr 2003 11:58:35 -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
> 

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.

Jeremy





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