Get name of class without instance
David Stanek
dstanek at dstanek.com
Wed Jun 24 12:47:59 EDT 2009
Try Foo.__name__ if Foo is a class object.
On 6/24/09, Bryan <bryanvick at gmail.com> wrote:
> Given a class:
>
> class Foo(object):
> pass
>
> How can I get the name "Foo" without having an instance of the class?
>
> str(Foo) gives me more than just the name Foo. "__main__.Account"
> Foo.__class__.__name__ gives me "type"
>
> I don't want to do:
> Foo().__class__.__name__ if possible. I would rather avoid the
> constructor. I just want to get a string "Foo"
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
Sent from my mobile device
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
More information about the Python-list
mailing list