It's called a super class but it doesn't quite work like a normal class.

>>> OBJ = object()
>>> OBJ.x = 3
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'object' object has no attribute 'x'

I can fix this by creating a NULL class.

>>> class NullObject(object): pass
...
>>> OBJ = NullObject()
>>> OBJ.x = 3
>>> OBJ.x
3
>>>

Is this behaviour (object not quite like a class) documented anywhere?
Does anyone know the rationale for this if any?

In case anyone wants to know why I am doing this, sometimes I simply
want an object to hold values that I can pass around.  I don't need
methods and I don't always know what variables I am going to need.

And yes, I know that dict is the usual way to do this.

-- 
D'Arcy J.M. Cain
Vybe Networks Inc.
http://www.VybeNetworks.com/
IM:da...@vex.net VoIP: sip:da...@vybenetworks.com
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to