Answers for "how to check if the classs has this attribute in pythpn"

5

python check if class has function

class A:
  def func():
    pass
hasattr(A(), 'func')
Posted by: Guest on July-03-2020
1

python check if attribute exists in class

if hasattr(obj, 'propertyName'):
	...
Posted by: Guest on March-10-2021

Code answers related to "how to check if the classs has this attribute in pythpn"

Python Answers by Framework

Browse Popular Code Answers by Language