Python library module implementation
Question: I am trying to write - and understand - some python code , and I have been
struggling to realize how python libraries are imported. Let me describe my
situation.

I am trying to mock a raspberry-pi-only python library (RPi.GPIO) in order to
run some unittests in my (x86) laptop. In order to accomplish that, I thought
I should just define the same functions, variables as the GPIO class, and have
all the functions emtpy (just pass). So I had a look at the RPi.GPIO module.

Although I thought I would find the actual implementation of the GPIO class
methods there, I actually saw that their body was empty. For example:

    
    
    def add_event_detect(*args, **kwargs): # real signature unknown
        """
        Enable edge detection events for a particular GPIO channel.
        channel      - either board pin number or BCM number depending on which mode is set.
        edge         - RISING, FALLING or BOTH
        [callback]   - A callback function for the event (optional)
        [bouncetime] - Switch bounce timeout in ms for callback
        """
        pass
    

So the question is, where is the actual implementation of this functions and
what is the point of this empty body? (just the pass keyword and the
documentation) How and by whom is this method overriden and gets the desired
functionality?


Answer: It should be a wrapper for a C function. And if you want to override
`__import__` as Zizouz212 mentioned, use import hooks instead.

Here is a PEP describing import hooks:
<https://www.python.org/dev/peps/pep-0302/>

