If I had a dictionary dict and I wanted to check for dict[\'key\'] I could either do so in a try block (bleh!) or use the get()<
dict
dict[\'key\']
try
get()<
Do you mean hasattr() perhaps?
hasattr()
hasattr(object, "attribute name") #Returns True or False
Python.org doc - Built in functions - hasattr()
You can also do this, which is a bit more cluttered and doesn't work for methods.
"attribute" in obj.__dict__