On Mon, 07 Jun 2010 15:04:35 -0600, Ian Kelly wrote: > I don't think that what you want to do here is possible. It appears to > be hard-coded and not affected by subclassing, as evidenced by the > following snippet: > > class NonDict(dict): > for attr in dict.__dict__: > if attr not in ('__init__', '__new__',): > locals()[attr] = None
I'm afraid your test is invalid. As the documentation states, you CANNOT write to locals() -- the change doesn't stick. This is nothing to do with dicts. >>> def f(): ... x = 1 ... locals()['x'] = 2 ... print x ... >>> f() 1 -- Steven -- http://mail.python.org/mailman/listinfo/python-list