New statement proposal for Python
Nick Perkins
nperkins7 at home.com
Fri Jun 15 19:10:12 EDT 2001
"Alex Martelli" <aleaxit at yahoo.com> wrote in message >
<snip excellent comments re: 'constants'>
> ...
> One (IMHO) Python enhancement would be to give dictionaries
> some finer-grained control on their degree of mutability.
> The ability to selectively make SOME existing keys non
> rebindable and/or non removable _would_ come in handy in
> quite a few places ('constants' included), as would the
> related ones of locking a dictionary against addition of
> new keys. Since ALMOST all Python namespaces are in fact
> dictionaries (local-variables of functions being the
> signal exception), such locking would give the basic
> semantics for several desirable tricks.
> ...
now, that's an interesting idea.
how would that look, syntactically?
dict['A']=1
dict.lock('A')
..making the value unchangeable?
..and would attempts to set the value raise an exception?
More information about the Python-list
mailing list