Answers for "check filed exist in object python"

17

check filed exist in object python

if hasattr(a, 'property'):
    a.property
Posted by: Guest on May-19-2020
0

check filed exist in object python

>>> class A(object):
... foo = 1
...
>>> class B(A):
... pass
...
>>> b = B()
>>> hasattr(b, 'foo')
True
>>> 'foo' in b.__dict__
False
Posted by: Guest on April-26-2022

Code answers related to "check filed exist in object python"

Python Answers by Framework

Browse Popular Code Answers by Language