To check if a Object has an Attribute in Python you can use the snippet below.

Sample Python

if hasattr(myObject, 'myAttributeName'): # myObject.myAttributeName exists.

6 thought on “How to check if a Object has an Attribute in Python”

Leave a Reply