__dict__ attribute for built-in types

candide candide at free.invalid
Thu Oct 27 10:01:25 EDT 2011


Le 27/10/2011 13:03, Duncan Booth a écrit :

>
>> -- where the official documentation refers to this point ?
>>
> See http://docs.python.org/reference/datamodel.html for the docs about
> __slots__
>
> There is also the API documentation which describes at a low level how
> to control whether or not instances have a dict:
>   http://docs.python.org/c-api/typeobj.html#tp_dictoffset
>
> I'm not sure though where you find a higher level statement of which
> builtin types have a __dict__.
>


OK, thanks for the information abouts the slots. Nevertheless, this 
cannot answer completely my question. Some builtin types like string, 
lists, integer, float, dictionaries, etc have the property that 
instances of those types don't provide a __dict__ attribute. I can't 
imagine the documentation lets pass silently this point.

But beside this, how to recognise classes whose object doesn't have a 
__dict__ attribute ?



More information about the Python-list mailing list