Johnny Lin wrote:
my understanding about locals() from the nutshell book was that i
should treat that dictionary as read-only. is it safe to use it to
delete entries?
No it's not:
py> def f():
... x = 1
... del locals()['x']
... print x
...
py> f()
1
py> def f():
... x = 1
... del x
... print x
...
py> f()
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "<interactive input>", line 4, in f
UnboundLocalError: local variable 'x' referenced before assignment
Steve
--
http://mail.python.org/mailman/listinfo/python-list