On Feb 17, 8:33 pm, deelan <[EMAIL PROTECTED]> wrote:
> Harlin Seritt wrote:
> > Hi,
>
> > How does one get the name of a class from within the class code? I
> > tried something like this as a guess:
>
> > self.__name__
>
> Get the class first, then inspect its name:
>
>  >>> class Foo(object): pass
> ...
>  >>> f = Foo()
>  >>> f.__class__.__name__
> 'Foo'
>  >>>
>


Why is the __name__ attribute not available to the instance? Why don't
normal lookup rules apply (meaning that a magic attribute will be
looked up on the class for instances) ?

Fuzzyman
http://www.voidspace.org.uk/python/articles.shtml


> HTH
>
> --
> d.


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

Reply via email to