Deleting variables referenced in nested scope

Jesse W jessw at loop.com
Sat Dec 22 00:45:53 CET 2001


	As I was playing arround with the new nested scopeing rules in 
Python 2.2a2, I got a SyntaxError I did not understand.  Here is the 
code:

def foo():
    x=5
    add=lambda a:x+a
    del x

When I ran this, I got this error:

SyntaxError: can not delete variable 'x' referenced in nested scope

What is this error?  Why is it here?  What does it mean?

		Thank you for your time,
			Jesse Weinstein




More information about the Python-list mailing list