Python – how to set default value for unavailable property

You can use getattr():
getattr(a, 'property', 'default value');
Here ‘a’ is the object you want to get ‘property’ from.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a comment