def flipped(interface):
    """
    Flip the data flow of the members of the interface object :py:`interface`.

    If an interface object is flipped twice, returns the original object:
    :py:`flipped(flipped(interface)) is interface`. Otherwise, wraps :py:`interface` in
    a :class:`FlippedInterface` proxy object that flips the directions of its members.

    See the documentation for the :class:`FlippedInterface` class for a detailed discussion of how
    this proxy object works.
    """
    if type(interface) is FlippedInterface:
        return interface._FlippedInterface__unflipped
    else:
        return FlippedInterface(interface)

    Flip the data flow of the members of the interface object :py:`interface`.

    If an interface object is flipped twice, returns the original object:
    :py:`flipped(flipped(interface)) is interface`. Otherwise, wraps :py:`interface` in
    a :class:`FlippedInterface` proxy object that flips the directions of its members.

    See the documentation for the :class:`FlippedInterface` class for a detailed discussion of how
    this proxy object works.
    
amaranth/lib/wiring.py