if hasattr(obj, 'attribute'): # do somthing VS try: # access obj.attribute except AttributeError, e: # deal with AttributeError 哪个应该是首选的,为什么?