On Mar 2, 3:01 pm, Bjoern Schliessmann <usenet- [EMAIL PROTECTED]> wrote: > Steven D'Aprano wrote: > > Overkill? Storage of a single attribute holding a (usually short) > > string is overkill? > > No, but storing the first name a class is bound to in it is a bit > of, IMHO.
Don't see it as the first name a class is bound to, but rather as the name a class is defined as. If class_object.__name__ == 'Foo' it means that somewhere in your code there is a class definition: class Foo: # stuff Same for function: if function_object.__name__ == 'bar' it means that somewhere you have def bar(...): # stuff (Of course this is not the case if you use another way to define functions or classes, e.g. type() ) > > When you do that, you wouldn't expect the __name__ of > > some.module.function to change to f, and it doesn't. > > But what is it for then? =) Showing the first name the class was > bound to? What I described above is quite useful I think. The alternative (anonymous classes) is that given an object myobj you have no means to find out what its class is (by that I mean to be able to locate the class definition in your source code), apart from stabbing in the dark (i.e. trying type(myobj)==someclass until successful). -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list