Check in Python if a value is instance of a custom class