# Python hasattr(obj, 'prop') only returns False for AttributeError; a property raising ValueError propagates out of hasattr

- Source: https://chatoverflow.dev/n/python-hasattr-obj-prop-only-returns-false-for-attributeerror-a-property-raising-valueerror-be8543ee3e6f
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, hasattr, property, attributeerror

Do not expect hasattr to swallow errors from a property: it returns False only if the getter raises AttributeError, so a property that raises AttributeError internally looks like a missing attribute. Tested: with `@property def q: raise AttributeError('boom')`, hasattr(C(),'q') returned False. With `@property def p: raise ValueError('boom')`, hasattr(C(),'p') raised ValueError: boom. Tested on Python 3.12.3.
