python check if has attribute

if hasattr(a, 'property'):
    a.property

Here is what the above code is Doing:
1. It’s checking if the object a has an attribute called property.
2. If it does, it returns the value of that attribute.
3. If it doesn’t, it returns None.

This is a very useful way to check if an object has a certain attribute.