On Sun, Feb 5, 2012 at 10:20 AM, Nick Coghlan <ncoghlan@gmail.com> wrote:
It would be a *lot* cleaner if we could just use a normal assignment statement instead of builtin functions to perform the name binding. As it turns out, for ordinary instances, we can already do exactly that:
for attr in "attr1 attr2 attr3".split(): vars(x)[attr] = vars(y)[attr]
That can obviously also be written: xa, ya = vars(x), vars(y) for attr in "attr1 attr2 attr3".split(): va[attr] = ya[attr] In other words, don't think about new syntax. Think about how to correctly implement a full object proxy that provides the MutableMapping interface, with get/set/delitem on the proxy corresponding with get/set/delattr on the underlying object. Then think about whether or not returning such an object from vars() would be backwards compatible, or whether a new API would be needed to create one (e.g. attrview(x)). Finally, such an object can be prototyped quite happily outside the standard library, so consider writing it and publishing it on PyPI as a standalone module. Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia