[issue7659] Attribute assignment on object() instances raises wrong exception

R. David Murray report at bugs.python.org
Fri Jan 8 19:57:52 CET 2010


R. David Murray <rdmurray at bitdance.com> added the comment:

But an object to which you can assign attributes but which has no methods can be useful in a number of contexts.  It's not a glorified dict, because attribute-style access is different from dict-style access.  The main place I have used this (creating my own trivial object subclass) is for passing a duck-typed object in to a function that only needs to access certain attributes to get the correct quack.

Why prevent us from using an object instance for this if there's not a functional reason for it?  Python is supposed to be a Consulting Adults language, after all :).

That said, I suspect that giving object a dict would break various assumptions in the core code, and I have no problem with creating that trivial subclass.  It does have the advantage of providing a more meaningful name in error messages.

----------
nosy: +r.david.murray

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7659>
_______________________________________


More information about the Python-bugs-list mailing list