def on_enter(__msg: Optional[Union[Callable, str]] = None) -> Callable:
    """Decorator to display a message when entering a function.

    Args:
        __msg: Message to display
    Returns:
        Wrapped function

    """
    # pylint: disable=missing-docstring
    def decorator(__func):
        @wraps(__func)
        def wrapper(*args, **kwargs):
            if __msg:
                print(__msg)
            else:
                print('Entering {!r}({!r})'.format(__func.__name__, __func))
            return __func(*args, **kwargs)
        return wrapper
    if callable(__msg):
        return on_enter()(__msg)
    return decorator
def on_enter ( __msg : Optional [ Union [ Callable , str ] ] = None ) -> Callable : def decorator ( __func ) : @ wraps ( __func ) def wrapper ( * args , ** kwargs ) : if __msg : print ( __msg ) else : print ( 'Entering {!r}({!r})' . format ( __func . __name__ , __func ) ) return __func ( * args , ** kwargs ) return wrapper if callable ( __msg ) : return on_enter ( ) ( __msg ) return decorator
Decorator to display a message when entering a function.

    Args:
        __msg: Message to display
    Returns:
        Wrapped function