Exploring Attributes and Methods

Paul McGuire ptmcg at austin.rr.com
Thu Mar 6 20:35:06 CET 2008

On Mar 6, 1:14 pm, "keios.ti... at gmail.com" <keios.ti... at gmail.com>
> Hi,
>  Is there a python command that allows me to extract the names (not
> values) of the attributes of a class.
> example
> Class Sample:
>     fullname = 'Something'
> How can I know that this class has an attribute called 'fullname'?
> I hope my question is clear.
> Thanks

If you had posted actual working code, "Class" would be all lower case
("class").  But we get the drift (in general, though, when posting
questions about examples from your code, best to copy-paste the actual
code, not a paraphrasing of it):

print Sample.__dict__.keys()


['__module__', 'fullname', '__doc__']

-- Paul

More information about the Python-list mailing list