Paul Rubin <http://[EMAIL PROTECTED]> writes: > "Giovanni Bajo" <[EMAIL PROTECTED]> writes: >> > However, when you prevent a client from adding an attribute, you're >> > not merely making your objects immutable, you're making them >> > static. > No I don't believe that. If an object is immutable, then > obj.serialize() should return the same string every time. If you can > add attributes then the serialization output will become different.
There isn't a standard serialize method in Python, so I don't know how you want to define it. I can think of perfectly reasonable definitions of serialize where obj.serialize() won't always return the same string on an immutable object, even if you don't allow adding attributes. Personally, I'd argue that serialize shouldn't return the extra attribute. If you want to add an attribute that gets serialized, you need to subclass the immutable class, add the attribute there, and extend serialize to include it. Whether or not that's reasonable depends on how you want to define serialize. <mike -- Mike Meyer <[EMAIL PROTECTED]> http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list