Skip to content

Commit 336f4bc

Browse files
committed
simplify by using hasattr
1 parent ac9394e commit 336f4bc

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

libzim/libzim.pyx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,7 @@ cdef object call_method(object obj, string method):
8989
cdef public api:
9090
bool obj_has_attribute(object obj, string attribute) with gil:
9191
"""Check if a object has a given attribute"""
92-
attr = getattr(obj, attribute.decode('UTF-8'), None)
93-
if not attr:
94-
return False
95-
return True
92+
return hasattr(obj, attribute.decode('UTF-8'))
9693

9794
string string_cy_call_fct(object obj, string method, string *error) with gil:
9895
"""Lookup and execute a pure virtual method on object returning a string"""

0 commit comments

Comments
 (0)