Using more Pythonic EAFP/duck-typing approach