hasattr test for static analysis, it's a common idiom.

This commit is contained in:
Dave Halter
2014-06-10 11:15:59 +02:00
parent c6aea92753
commit bba120d906

View File

@@ -49,3 +49,18 @@ try:
#! 4 attribute-error #! 4 attribute-error
str.not_existing str.not_existing
except [AttributeError]: pass except [AttributeError]: pass
# -----------------
# kind of similar: hasattr
# -----------------
if hasattr(object, 'undefined'):
str.undefined
str.upper
#! 4 attribute-error
str.undefined2
else:
str.upper
#! 4 attribute-error
str.undefined