0

I am searching through method/class declarations in Pycharm and I made it down to __builtin__.py, but there does not appear to be any code written in this module.

Here is the snippet that I came across:

def hasattr(p_object, name): # real signature unknown; restored from __doc__
    """
    hasattr(object, name) -> bool

    Return whether the object has an attribute with the given name.
    (This is done by calling getattr(object, name) and catching exceptions.)
    """
    return False

Where is the code that is actually executed when I call hasattr()? Is the line # real signature unknown; restored from __doc__ a clue as to why there is no code here?

I am not interested in changing anything. I am simply surprised that there is no code written here.

Ian
  • 933
  • 12
  • 17

1 Answers1

1

They are built in functions.

It means that they are a direct calls to methods embedded in python binaries. Simply, the python code for them doesn't exist.

woockashek
  • 1,588
  • 10
  • 25