object() can't have attributes
Neal Becker
ndbecker2 at gmail.com
Wed Dec 23 07:46:00 EST 2015
I'm a bit surprised that an object() can't have attributes:
In [30]: o = object()
In [31]: o.x = 2
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-31-815c47907397> in <module>()
----> 1 o.x = 2
AttributeError: 'object' object has no attribute 'x'
Sometimes I want to collect attributes on an object. Usually I would make
an empty class for this. But it seems unnecessarily verbose to do this. So
I thought, why not just use an Object? But no, an instance of Object
apparantly can't have an attribute. Is this intentional?
More information about the Python-list
mailing list