Python hasattr vs getattr
I have been reading lately some tweets and the python documentation about hasattr and it says: hasattr(object, name) The arguments are an object and a string. The result is True if the string is the name of >> one of the object’s attributes, False if not. (This is implemented by calling getattr(object, name) and seeing whether it raises an AttributeError or not.) There is a motto in Python that says that is Easier to ask for forgiveness than permission where I usually agree. I tried to do a performance test in this case with a really simple python code: import timeit definition="""\ class A