Duck-typing snippet improved

- added example with hasattr() function (should be preferred)