[Tutor] attribute of built-in type

Kent Johnson kent37 at tds.net
Fri Nov 28 23:18:51 CET 2008


On Fri, Nov 28, 2008 at 3:55 PM, spir <denis.spir at free.fr> wrote:
> I try to find a way to give a cutom type ('s instances) attributes like some
> built-in types have, for instance __name__. (For any reason, such attributes
> are not equally shared by all kinds of objects.)
> I tried to achieve that with inheritance, but I couldn't make it work with
> built-in types. I suspect I should use metatypes -- but have no experience
> in that field. It is probably not a proper use, anyway.

I'm not sure what you are trying to accomplish. Custom classes have
__name__ attributes; instances of built-in and custom classes don't
have __name__ attributes.

Kent


More information about the Tutor mailing list