Exploring Attributes and Methods

Tim Chase python.list at tim.thechases.com
Thu Mar 6 14:39:38 EST 2008


> Class Sample:
>     fullname = 'Something'
> 
> How can I know that this class has an attribute called 'fullname'?

with the builtin hasattr() function :)

 >>> class Sample: fullname='Something'
...
 >>> hasattr(Sample, 'fullname')
True

-tkc





More information about the Python-list mailing list