mirror of
https://github.com/davidhalter/jedi.git
synced 2026-10-17 07:21:25 +08:00
hasattr test for static analysis, it's a common idiom.
This commit is contained in:
1 parent
c6aea92753
commit
bba120d906
1 file changed
+15
@@ -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
|
||||||
Reference in new issue
Block a user