I wanted to create a throwaway "struct" object to keep various status flags. My first approach was this (javascript style)
>>> status = object()
>>> status.foo = 3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'object' object has no attribute 'foo'
Definitely not what I expected, because this works:
>>> class Anon: pass
...
>>> b=Anon()
>>> b.foo = 4
I guess this is because object() does not have a __dict__
. I don't want to use a dictionary, and assuming I don't want to create the Anon object, is there another solution ?