diff options
author | Raymond Hettinger <python@rcn.com> | 2011-01-20 04:12:37 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2011-01-20 04:12:37 (GMT) |
commit | 03ca1a92af361c66f21398d597a61892e04029a8 (patch) | |
tree | d8dbdc46e252318e1686dede78032c3c11cf3344 /Doc/whatsnew/3.2.rst | |
parent | a275c989c9b97896ef6d0ff6598572e2d663c7b7 (diff) | |
download | cpython-03ca1a92af361c66f21398d597a61892e04029a8.zip cpython-03ca1a92af361c66f21398d597a61892e04029a8.tar.gz cpython-03ca1a92af361c66f21398d597a61892e04029a8.tar.bz2 |
Add hasattr() example.
Diffstat (limited to 'Doc/whatsnew/3.2.rst')
-rw-r--r-- | Doc/whatsnew/3.2.rst | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/Doc/whatsnew/3.2.rst b/Doc/whatsnew/3.2.rst index 518ea50..3d878c6 100644 --- a/Doc/whatsnew/3.2.rst +++ b/Doc/whatsnew/3.2.rst @@ -456,7 +456,18 @@ Some smaller changes made to the core Python language are: would otherwise be absent from the class dictionary. Formerly, *hasattr* would catch any exception, possibly masking genuine errors. Now, *hasattr* has been tightened to only catch :exc:`AttributeError` and let other - exceptions pass through. + exceptions pass through:: + + >>> class A: + @property + def f(self): + return 1 // 0 + + >>> a = A() + >>> hasattr(a, 'f') + Traceback (most recent call last): + ... + ZeroDivisionError: integer division or modulo by zero (Discovered by Yury Selivanov and fixed by Benjamin Peterson; :issue:`9666`.) |