On 10/27/2011 6:52 PM, candide wrote:

No but I'm expecting from Python documentation to mention the laws of
Python ...

The details of CPython builtin classes are not laws of Python. It *is* a 'law of Python' that classes can use 'slots = ' to restrict the attributes of instances. By implication, builtin classes in any implementation do not have to allow attribute assignment. I do not believe it would be a violation if some implementation did so.

None of this is to say that we could not say something on the subject at the beginning of the 'built-in types' chapter of the lib manual.

OK but I'm talking about classes, not instances :

Yes you are. The class determines whether its instances have assignable new attributes.

> 42 has no __dict__ > attribute but,
> may be, 43 _has_ such attribute, who knows in advance ? ;)

True, in a sense, but if the class allowed a user to execute
"42.__dict__ = {}" then you could safely assume that "43.xxx = z" should work also.

--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to